.dice-view {
  position: fixed;
  z-index: 7;
  top: calc(88px + max(8px, env(safe-area-inset-top)) + var(--telegram-fullscreen-top-gap, 0px));
  bottom: 0;
  display: flex;
  width: min(100vw, 460px);
  left: max(0px, calc((100vw - 460px) / 2));
  right: auto;
  flex-direction: column;
  margin: 0;
  padding: calc(64px + max(10px, env(safe-area-inset-top)) + var(--telegram-fullscreen-top-gap, 0px)) var(--pvp-content-gutter) max(98px, calc(90px + env(safe-area-inset-bottom)));
  overflow-y: auto;
  scrollbar-width: none;
  background: linear-gradient(180deg, #111113, #19191d 55%, #111113);
  color: #f7f7f9;
  overscroll-behavior: contain;
}

.dice-view::-webkit-scrollbar { display: none; }
.dice-view[hidden] { display: none; }
body .app:has(.dice-view:not([hidden])) .dice-view { top: 0; }
.dice-header { position: relative; display: grid; min-height: 42px; grid-template-columns: 42px minmax(0, 1fr) minmax(106px, max-content); align-items: center; gap: 8px; }
.dice-header h1 { position: absolute; top: 50%; left: 50%; margin: 0; font-size: 17px; font-weight: 900; text-align: center; transform: translate(-50%, calc(-50% - 30px)); }
.dice-back { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #303036; border-radius: 50%; background: #202024; color: #e8e8eb; font-size: 26px; line-height: 1; cursor: pointer; }
.dice-balance { display: flex; width: auto; min-width: 106px; height: 37px; grid-column: 3; justify-self: end; align-items: center; justify-content: center; gap: 6px; padding: 0 9px; border: 1px solid #34343a; border-radius: 20px; background: #242428; color: #fff; cursor: pointer; }
.dice-balance .gram-logo { width: 17px; height: 17px; }
.dice-balance strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.dice-balance b { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: #3c3c43; font-size: 15px; }
.dice-content { display: flex; flex: 1; flex-direction: column; gap: 12px; padding-top: 12px; }

.dice-roll-card, .dice-options-card, .dice-bet-card { border: 1px solid rgba(255,255,255,.055); border-radius: 22px; background: linear-gradient(145deg, #202025, #19191d); }
.dice-roll-card { padding: 20px 8px 28px; }
.dice-roll-range { display: flex; justify-content: space-between; color: #8f8e96; font-size: 11px; font-weight: 700; }
.dice-roll-range strong { visibility: hidden; color: #d6d4dc; font-size: 10px; font-weight: 700; }
.dice-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 19px 0 2px; color: #9a98a1; font-size: 10px; }
.dice-scale span { text-align: center; }
.dice-scale span:first-child { text-align: left; }
.dice-scale span:last-child { text-align: right; }
.dice-slider-wrap { position: relative; padding-top: 12px; }
.dice-slider-track { --dice-boundary: 50%; position: relative; height: 20px; border-radius: 999px; background: linear-gradient(90deg, #fa1742 0%, #fa1742 var(--dice-boundary), #13df69 var(--dice-boundary), #13df69 100%); box-shadow: 0 0 18px rgba(51,220,102,.12), 0 0 16px rgba(255,24,69,.1); }
.dice-slider-track::before { position: absolute; z-index: 1; inset: 0; border-radius: inherit; background: repeating-linear-gradient(125deg, rgba(255,255,255,.18) 0 2px, transparent 2px 5px); content: ""; pointer-events: none; }
.dice-slider-track--under { background: linear-gradient(90deg, #13df69 0%, #13df69 var(--dice-boundary), #fa1742 var(--dice-boundary), #fa1742 100%); }
#dice-threshold-slider { position: absolute; z-index: 2; inset: -8px 0; width: 100%; height: 36px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
#dice-threshold-slider::-webkit-slider-runnable-track { height: 20px; background: transparent; }
#dice-threshold-slider::-moz-range-track { height: 20px; background: transparent; }
#dice-threshold-slider::-webkit-slider-thumb { width: 36px; height: 36px; margin-top: -8px; appearance: none; border: 6px solid #fff; border-radius: 50%; background: #5c4ad1; box-shadow: 0 2px 7px rgba(0,0,0,.45); }
#dice-threshold-slider::-moz-range-thumb { width: 24px; height: 24px; border: 6px solid #fff; border-radius: 50%; background: #5c4ad1; box-shadow: 0 2px 7px rgba(0,0,0,.45); }
.dice-tick-marks { position: absolute; top: 0; right: 0; left: 0; display: grid; height: 5px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dice-tick-marks i { width: 0; height: 0; justify-self: center; border-top: 5px solid #8f8e96; border-right: 4px solid transparent; border-left: 4px solid transparent; }
.dice-result-marker { position: absolute; z-index: 3; top: 50%; width: 5px; height: 28px; border: 1px solid #fff; border-radius: 4px; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.8); transform: translate(-50%,-50%); transition: left .2s ease; pointer-events: none; }
.dice-result-marker--win { background: #27f27b; }
.dice-result-marker--loss { background: #ff3153; }

.dice-options-card { display: flex; flex-direction: column; gap: 16px; padding: 30px 17px 18px; }
.dice-fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.dice-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #a7a6ad; font-size: 11px; }
.dice-field-value, .dice-input-action, .dice-amount-wrap { display: flex; min-width: 0; height: 56px; align-items: center; justify-content: space-between; gap: 8px; padding: 0 15px; border: 1px solid #33333a; border-radius: 16px; background: #242429; color: #f4f4f6; }
.dice-field-value { font-size: 20px; font-variant-numeric: tabular-nums; }
.dice-field-value small { color: #888790; font-size: 20px; font-weight: 500; }
.dice-input-action input, .dice-amount-wrap input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: #f4f4f6; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dice-input-action input::-webkit-inner-spin-button, .dice-input-action input::-webkit-outer-spin-button, .dice-amount-wrap input::-webkit-inner-spin-button, .dice-amount-wrap input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.dice-switch { flex: 0 0 auto; padding: 0; border: 0; background: transparent; color: #aaa9b1; font-size: 21px; cursor: pointer; }

.dice-bet-card { display: flex; flex-direction: column; gap: 12px; padding: 15px; }
.dice-amount-wrap strong { flex: 0 0 auto; color: #57bff1; font-size: 12px; }
.dice-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.dice-presets button { min-height: 33px; border: 1px solid #35353b; border-radius: 11px; background: #26262b; color: #d5d4da; font-size: 11px; font-weight: 700; cursor: pointer; }
.dice-presets button:disabled { opacity: .55; cursor: not-allowed; }
.dice-input-action input:disabled, .dice-amount-wrap input:disabled { opacity: .7; }
.dice-bet-button { min-height: 49px; border: 0; border-radius: 15px; background: linear-gradient(180deg, #a947ed, #7822c1); color: #fff; font-size: 14px; font-weight: 800; cursor: pointer; }
.dice-bet-button:disabled { background: #33333a; color: #77767e; cursor: not-allowed; }
.dice-deposit-link { align-self: center; padding: 2px 8px; border: 0; background: transparent; color: #aaa9b1; font-size: 10px; cursor: pointer; }
.dice-message { min-height: 15px; margin: -3px 0 0; color: #a5a4ac; font-size: 10px; line-height: 1.4; text-align: center; }
.dice-message--win { color: #52e995; }
.dice-message--loss, .dice-message--error { color: #ff7a8b; }
.dice-fairness-note { margin: auto 2px 0; padding-top: 4px; color: #77767e; font-size: 9px; line-height: 1.45; text-align: center; }
.dice-view ~ .bottom-nav { z-index: 8; }

@media (max-width: 360px) {
  .dice-view { padding-right: var(--pvp-content-gutter); padding-left: var(--pvp-content-gutter); }
  .dice-content { gap: 9px; padding-top: 8px; }
  .dice-roll-card { padding: 20px 8px 28px; }
  .dice-options-card { gap: 16px; padding: 30px 17px 18px; }
  .dice-fields-row { gap: 8px; }
  .dice-field-value, .dice-input-action, .dice-amount-wrap { height: 56px; padding: 0 15px; }
}
