/* Dice game (public/js/pages/dice.js) */
.dice { --t: 49.5; --win-a: #5ee6b4; --win-b: #1fa877; --lose-a: #ff6b6b; --lose-b: #b3262b;
  display: flex; flex-direction: column; justify-content: center; gap: 26px; min-height: 380px; max-width: 900px; margin: 0 auto; }

/* ---------------------------------------------------------------- result number */
.dice-result { position: relative; text-align: center; padding: 26px 0 4px; isolation: isolate; }
.dice-result::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: min(520px, 100%); height: 190px; z-index: -1;
  transform: translate(-50%, -55%); border-radius: 50%; opacity: 0; transition: opacity .35s, background .35s;
}
.dice-result.win::before { opacity: 1; background: radial-gradient(closest-side, rgba(52, 211, 153, .2), transparent); }
.dice-result.lose::before { opacity: 1; background: radial-gradient(closest-side, rgba(255, 92, 92, .14), transparent); }
.dice-num {
  font: 800 88px/1 var(--font); letter-spacing: -.01em; font-variant-numeric: tabular-nums;
  color: var(--text); transition: color .2s, text-shadow .3s, opacity .2s; will-change: transform;
}
.dice-num.idle { color: var(--dim); }
.dice-num.pending { opacity: .55; }
.dice-num.win { color: var(--green); text-shadow: 0 0 42px rgba(52, 211, 153, .45); }
.dice-num.lose { color: var(--red); text-shadow: 0 0 42px rgba(255, 92, 92, .32); }
.dice-num.pop { animation: dice-pop .5s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes dice-pop { 0% { transform: scale(.88); } 50% { transform: scale(1.07); } 100% { transform: scale(1); } }
.dice-sub { margin-top: 10px; color: var(--muted); font-size: 14.5px; }
.dice-sub b { color: var(--text); font-variant-numeric: tabular-nums; }
.dice-sub .dice-sub-mult { color: var(--accent-hi); }
.dice-pop {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 4px; font-size: 20px; font-weight: 800; color: var(--green); white-space: nowrap;
}
.dice-pop .price { gap: 5px; }
.dice-pop.go { animation: dice-float 1.2s ease-out forwards; }
@keyframes dice-float {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(.9); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(1); }
}

/* ---------------------------------------------------------------- slider */
.dice-slider { padding-top: 50px; }
.dice-rail {
  padding: 14px 18px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line2);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .45), 0 10px 30px -18px rgba(239, 59, 59, .5);
}
.dice-track { position: relative; height: 12px; }
.dice-zones {
  position: absolute; inset: 0; border-radius: 99px; overflow: hidden;
  background: linear-gradient(180deg, var(--lose-a), var(--lose-b));
  box-shadow: 0 0 18px -4px rgba(255, 92, 92, .35);
}
.dice-fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: calc(var(--t) * 1%);
  background: linear-gradient(180deg, var(--win-a), var(--win-b)); box-shadow: 0 0 16px rgba(52, 211, 153, .45);
}
.dice.over .dice-fill { left: calc(var(--t) * 1%); width: auto; right: 0; }

.dice-marker {
  --r: 0; position: absolute; left: calc(var(--r) * 1%); bottom: calc(100% + 20px); z-index: 3;
  transform: translateX(-50%); pointer-events: none; opacity: 0; transition: opacity .2s;
}
.dice-marker.show { opacity: 1; }
.dice-marker span {
  position: relative; display: block; min-width: 64px; padding: 7px 10px; border-radius: 10px; text-align: center;
  background: var(--panel3); border: 1px solid var(--line2); color: var(--text);
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .5); transition: background .2s, color .2s, border-color .2s;
}
.dice-marker span::after {
  content: ''; position: absolute; left: 50%; top: 100%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: inherit; border: inherit; border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.dice-marker.win span { background: var(--green); border-color: var(--green); color: #052a1c; box-shadow: 0 8px 26px rgba(52, 211, 153, .45); }
.dice-marker.lose span { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 8px 26px rgba(255, 92, 92, .4); }
.dice-marker.land span { animation: dice-land .4s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes dice-land { 0% { transform: translateY(-6px) scale(.92); } 100% { transform: none; } }

/* Native range input, stretched by the thumb width so the thumb centre sits exactly on the value */
.dice-range {
  position: absolute; left: -15px; top: 50%; z-index: 2; width: calc(100% + 30px); height: 44px; margin: 0;
  transform: translateY(-50%); background: none; -webkit-appearance: none; appearance: none; cursor: grab; outline: none;
}
.dice-range:active { cursor: grabbing; }
.dice-range:disabled { cursor: not-allowed; }
.dice-range::-webkit-slider-runnable-track { height: 44px; background: transparent; border: 0; }
.dice-range::-moz-range-track { height: 44px; background: transparent; border: 0; }
.dice-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 30px; height: 30px; margin-top: 7px; border: 0; border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 10px, #b9aab0 10px 12px, transparent 12px 14px, #b9aab0 14px 16px, transparent 16px 18px, #b9aab0 18px 20px, transparent 20px) center / 100% 12px no-repeat,
    linear-gradient(180deg, #ffffff, #ddd3d6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .55), 0 0 0 4px rgba(239, 59, 59, .3);
  transition: box-shadow .15s, transform .15s;
}
.dice-range::-moz-range-thumb {
  width: 30px; height: 30px; border: 0; border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 10px, #b9aab0 10px 12px, transparent 12px 14px, #b9aab0 14px 16px, transparent 16px 18px, #b9aab0 18px 20px, transparent 20px) center / 100% 12px no-repeat,
    linear-gradient(180deg, #ffffff, #ddd3d6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .55), 0 0 0 4px rgba(239, 59, 59, .3);
}
.dice-range:hover::-webkit-slider-thumb, .dice-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 4px 14px rgba(0, 0, 0, .55), 0 0 0 6px rgba(239, 59, 59, .45); transform: scale(1.06); }
.dice-range:hover::-moz-range-thumb, .dice-range:focus-visible::-moz-range-thumb { box-shadow: 0 4px 14px rgba(0, 0, 0, .55), 0 0 0 6px rgba(239, 59, 59, .45); }
.dice-running .dice-range::-webkit-slider-thumb { box-shadow: 0 4px 14px rgba(0, 0, 0, .55); }

.dice-scale { position: relative; height: 18px; margin: 10px 18px 0; font-size: 12px; font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums; }
.dice-scale span { position: absolute; top: 0; transform: translateX(-50%); }

/* ---------------------------------------------------------------- linked fields */
.dice-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dice-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dice-field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dice-input {
  display: flex; align-items: center; gap: 4px; height: 46px; padding: 0 6px 0 14px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line2); transition: border-color .15s, box-shadow .15s;
}
.dice-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(239, 59, 59, .12); }
/* width: 0 + flex: 1 - the input fills the box without its default ~20ch width stretching the page on phones */
.dice-input input {
  flex: 1; width: 0; min-width: 0; height: 100%; padding: 0; border: 0; outline: none; background: none;
  font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.dice-input i { font-style: normal; font-weight: 700; color: var(--muted); padding: 0 8px 0 2px; }
.dice-input.invalid, .bet-input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 92, 92, .12); }
.dice-flip {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: var(--panel3); color: var(--accent-hi); cursor: pointer; transition: background .15s, transform .35s cubic-bezier(.2, .9, .3, 1.3);
}
.dice-flip:hover { background: var(--line2); }
.dice-flip.turned { transform: rotate(180deg); }
.dice-flip:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- recent rolls */
.dice-history-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dice-history-label { flex: none; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dice-history {
  flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.dice-history::-webkit-scrollbar { display: none; }
.dice-history-empty { color: var(--dim); font-size: 13px; white-space: nowrap; }
.dice-chip {
  flex: none; padding: 5px 10px; border-radius: 8px; border: 1px solid transparent;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.dice-chip.win { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .32); color: var(--green); }
.dice-chip.lose { background: rgba(255, 92, 92, .1); border-color: rgba(255, 92, 92, .28); color: var(--red); }
.dice-chip.new { animation: dice-chip-in .4s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes dice-chip-in { from { opacity: 0; transform: translateX(-14px) scale(.7); } }

/* ---------------------------------------------------------------- controls */
.dice-panel { display: flex; flex-direction: column; gap: 14px; }
.dice-roll { position: relative; overflow: hidden; }
.dice-roll kbd {
  font: 600 11px/1 var(--font); padding: 4px 6px; border-radius: 5px; letter-spacing: .04em;
  background: rgba(0, 0, 0, .22); color: rgba(255, 255, 255, .85);
}
.dice-roll.rolling::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%);
  transform: translateX(-100%); animation: dice-shine .7s ease-in-out infinite;
}
@keyframes dice-shine { to { transform: translateX(100%); } }
@media (hover: none) { .dice-roll kbd { display: none; } }
.dice-profit { color: var(--green); }
/* Same for the shared bet field: its number input's default width would widen the page on phones */
.dice-page .bet-input .input { width: 0; }

.dice-check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 500; user-select: none; }
.dice-check input {
  flex: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 99px; cursor: pointer;
  -webkit-appearance: none; appearance: none; background: var(--panel3); border: 1px solid var(--line2); transition: background .2s, border-color .2s;
}
.dice-check input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); transition: transform .2s cubic-bezier(.2, .9, .3, 1.3);
}
.dice-check input:checked { background: var(--accent); border-color: var(--accent); }
.dice-check input:checked::after { transform: translateX(16px); }
.dice-check input:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.dice-check input:disabled { opacity: .5; cursor: not-allowed; }

.dice-auto { display: flex; flex-direction: column; gap: 10px; }
.dice-progress { height: 5px; border-radius: 99px; background: var(--bg2); overflow: hidden; }
.dice-progress i {
  --p: 0; display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-lo), var(--accent-hi)); transition: width .3s ease;
}
.dice-auto-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dice-auto-grid div { padding: 8px 6px; border-radius: 9px; background: var(--bg2); text-align: center; }
.dice-auto-grid span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dice-auto-grid b { display: block; margin-top: 2px; font-size: 14.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dice-auto-grid b.pos { color: var(--green); }
.dice-auto-grid b.neg { color: var(--red); }
.dice-auto-note { font-size: 12.5px; color: var(--muted); min-height: 1em; }
.dice-auto-note:empty { display: none; }

.dice-running .dice-slider, .dice-running .dice-fields { opacity: .75; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .dice { min-height: 0; gap: 22px; }
}
@media (max-width: 600px) {
  .dice-num { font-size: 64px; }
  .dice-result { padding-top: 24px; }
  .dice-slider { padding-top: 46px; }
  .dice-rail { padding: 12px 16px; }
  .dice-scale { margin: 8px 16px 0; }
  .dice-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dice-field-target { grid-column: 1 / -1; order: -1; }
  .dice-input { height: 44px; }
  .dice-marker span { min-width: 56px; padding: 6px 8px; font-size: 14px; }
}
