/* European roulette engine — SVG wheel, felt betting board, chips. */

.qt-rl {
  --qt-rl-felt: #0c4a34;
  --qt-rl-red: #d3233c;
  --qt-rl-black: #17171f;
  --qt-rl-green: #12a35e;
  container-type: inline-size;
  width: min(100%, 980px);
  margin-inline: auto;
  color: var(--qt-ink, #f6f1ff);
  -webkit-tap-highlight-color: transparent;
}
.qt-rl-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "wheel" "board" "controls" "status";
  gap: clamp(10px, 2cqi, 16px);
}

.qt-rl-wheelpanel,
.qt-rl-boardpanel,
.qt-rl-controls {
  border-radius: var(--qt-r, 16px);
  background: var(--qt-panel, rgba(16, 10, 30, .72));
  border: 1px solid var(--qt-line, rgba(255, 255, 255, .12));
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(10px);
}

/* ---------- wheel panel ---------- */
.qt-rl-wheelpanel {
  grid-area: wheel;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  background:
    radial-gradient(90% 80% at 30% 50%, color-mix(in srgb, var(--qt-accent, #ff4a5f) 22%, transparent), transparent 70%),
    var(--qt-panel, rgba(16, 10, 30, .72));
}
.qt-rl-wheelbox {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 340px;
  justify-self: center;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .55));
}
.qt-rl-wheel { display: block; width: 100%; height: 100%; }
.qt-rl-wnum {
  fill: #fff;
  font-size: 15px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  font-family: inherit;
}
.qt-rl-ball { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6)); }

.qt-rl-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.qt-rl-result {
  display: flex;
  align-items: center;
  gap: 12px;
}
.qt-rl-result-n {
  flex: 0 0 auto;
  width: clamp(54px, 15cqi, 84px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(22px, 6cqi, 36px);
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .08);
  border: 2px solid rgba(255, 255, 255, .2);
}
.qt-rl-result-n.is-red { background: radial-gradient(circle at 35% 30%, #ff6b7e, var(--qt-rl-red) 70%); border-color: #ffd0d6; }
.qt-rl-result-n.is-black { background: radial-gradient(circle at 35% 30%, #4a4a5c, var(--qt-rl-black) 70%); border-color: #c9c9d6; }
.qt-rl-result-n.is-green { background: radial-gradient(circle at 35% 30%, #4fe39a, var(--qt-rl-green) 70%); border-color: #c8ffe2; }
.qt-rl-result-n.is-pop {
  animation: qt-rl-pop .36s cubic-bezier(.2, .9, .3, 1.35) both;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--qt-gold, #ffcf4a) 60%, transparent), 0 0 30px rgba(255, 207, 74, .45);
}
@keyframes qt-rl-pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.qt-rl-result-c {
  font-weight: 700;
  font-size: clamp(13px, 3.2cqi, 16px);
  line-height: 1.3;
  color: rgba(246, 241, 255, .86);
}

.qt-rl-hist { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qt-rl-hist-l {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--qt-muted, #b9b0d6);
}
.qt-rl-hist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 30px;
}
.qt-rl-hist-n {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255, 255, 255, .18);
}
.qt-rl-hist-n.is-red { background: var(--qt-rl-red); }
.qt-rl-hist-n.is-black { background: var(--qt-rl-black); }
.qt-rl-hist-n.is-green { background: var(--qt-rl-green); }
.qt-rl-hist-n.is-new { box-shadow: 0 0 0 2px var(--qt-gold, #ffcf4a); animation: qt-rl-pop .3s ease-out both; }

/* ---------- board ---------- */
.qt-rl-boardpanel {
  grid-area: board;
  padding: clamp(10px, 2.2cqi, 18px);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .1), transparent 60%),
    repeating-radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .02) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--qt-rl-felt), color-mix(in srgb, var(--qt-rl-felt) 55%, #000));
  box-shadow:
    0 0 0 4px #2a170c,
    0 0 0 6px color-mix(in srgb, var(--qt-gold, #ffcf4a) 55%, transparent),
    0 22px 50px rgba(0, 0, 0, .5);
}
.qt-rl-board {
  --qt-rl-hs: 18px;
  --qt-rl-chip: clamp(24px, 4.2cqi, 32px);
  position: relative;
  display: grid;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .55);
  grid-template-columns: 1.15fr repeat(12, minmax(0, 1fr)) 1.15fr;
  grid-template-rows: repeat(3, clamp(40px, 6.4cqi, 58px)) clamp(34px, 5cqi, 44px) clamp(34px, 5cqi, 44px);
  user-select: none;
}
.qt-rl.is-spinning .qt-rl-board { cursor: default; }

.qt-rl-fill {
  grid-column: var(--hc);
  grid-row: var(--hr);
  background: var(--qt-rl-felt);
}
.qt-rl-cell {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  font: inherit;
  color: #fff;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  grid-column: var(--hc);
  grid-row: var(--hr);
  background: var(--qt-rl-felt);
  transition: filter .15s ease-out, box-shadow .15s ease-out;
}
.qt-rl-cell:focus-visible { outline: 3px solid #fff; outline-offset: -3px; z-index: 4; }
.qt-rl-cell-n {
  font-weight: 800;
  font-size: clamp(13px, 2.4cqi, 18px);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  pointer-events: none;
}
.qt-rl-cell--num.is-red { background: linear-gradient(180deg, #e8384f, #b81a31); }
.qt-rl-cell--num.is-black { background: linear-gradient(180deg, #2a2a36, #101016); }
.qt-rl-cell--num.is-green { background: linear-gradient(180deg, #19c272, #0d7f49); border-radius: 8px 0 0 8px; }
.qt-rl-cell--out .qt-rl-cell-n { font-size: clamp(11px, 2cqi, 15px); letter-spacing: .04em; }
.qt-rl-cell--col { border-radius: 0; }
.qt-rl-cell.is-hint { filter: brightness(1.35); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8); }
.qt-rl-cell:hover { filter: brightness(1.18); }
.qt-rl.is-spinning .qt-rl-cell { cursor: default; filter: none; }
.qt-rl-cell.is-hit {
  z-index: 2;
  box-shadow: inset 0 0 0 3px var(--qt-gold, #ffcf4a), 0 0 22px var(--qt-gold, #ffcf4a);
  animation: qt-rl-hit .6s ease-out 3;
}
@keyframes qt-rl-hit { 50% { filter: brightness(1.6); } }

.qt-rl-diamond {
  width: 34%;
  max-width: 34px;
  aspect-ratio: 1.6;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  pointer-events: none;
}
.qt-rl-diamond.is-red { background: linear-gradient(180deg, #ff5a6f, var(--qt-rl-red)); }
.qt-rl-diamond.is-black { background: linear-gradient(180deg, #4a4a5c, #08080c); box-shadow: 0 0 0 1px #fff; }
.qt-rl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* inside-bet hot spots, positioned on cell edges (horizontal board) */
.qt-rl-hs {
  position: absolute;
  z-index: 6;
  width: var(--qt-rl-hs);
  height: var(--qt-rl-hs);
  border-radius: 50%;
  cursor: pointer;
  transform: translate(-50%, -50%);
}
.qt-rl-hs--r { left: 100%; top: 50%; }
.qt-rl-hs--t { left: 50%; top: 0; }
.qt-rl-hs--tr { left: 100%; top: 0; }
.qt-rl-hs--b { left: 50%; top: 100%; }
.qt-rl-hs--br { left: 100%; top: 100%; }
@media (hover: hover) {
  .qt-rl-hs:hover { background: rgba(255, 255, 255, .35); box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
}
.qt-rl.is-spinning .qt-rl-hs { pointer-events: none; }

/* ---------- chips ---------- */
.qt-rl-chip {
  --qt-rl-c: #3d7bff;
  width: var(--qt-rl-chip, 30px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: repeating-conic-gradient(from 8deg, var(--qt-rl-c) 0 22deg, #f6f0e2 22deg 30deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .45), 0 4px 8px rgba(0, 0, 0, .4), inset 0 0 0 1.5px rgba(0, 0, 0, .2);
  pointer-events: none;
}
.qt-rl-chip-v {
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, .7);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--qt-rl-c) 55%, #fff), var(--qt-rl-c) 70%);
  color: #fff;
  font-weight: 900;
  font-size: calc(var(--qt-rl-chip, 30px) * .3);
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .5);
  white-space: nowrap;
}
.qt-rl-chip-v.is-long { font-size: calc(var(--qt-rl-chip, 30px) * .22); letter-spacing: -.06em; }
.qt-rl-chip--placed {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  transition: opacity .3s ease-out, transform .3s ease-out;
}
.qt-rl-hs > .qt-rl-chip--placed { --qt-rl-chip: clamp(22px, 3.6cqi, 28px); }
.qt-rl-chip.is-stack { box-shadow: 0 2px 0 rgba(0, 0, 0, .45), 0 -3px 0 -1px color-mix(in srgb, var(--qt-rl-c) 70%, #000), 0 -5px 0 -1px #f6f0e2, 0 6px 10px rgba(0, 0, 0, .45); }
.qt-rl-chip.is-lose { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
.qt-rl-chip.is-win {
  transform: translate(-50%, -50%) scale(1.18);
  box-shadow: 0 0 0 3px var(--qt-gold, #ffcf4a), 0 0 20px rgba(255, 207, 74, .8), 0 4px 8px rgba(0, 0, 0, .4);
}
.qt-rl-chip--blue { --qt-rl-c: #3d7bff; }
.qt-rl-chip--red { --qt-rl-c: #e8344f; }
.qt-rl-chip--green { --qt-rl-c: #17a874; }
.qt-rl-chip--violet { --qt-rl-c: #8a5cff; }
.qt-rl-chip--orange { --qt-rl-c: #f28a1a; }
.qt-rl-chip--gold { --qt-rl-c: #d9a910; }
.qt-rl-chip--onyx { --qt-rl-c: #23262f; }
.qt-rl-chip--onyx .qt-rl-chip-v { color: var(--qt-gold, #ffcf4a); }

/* ---------- controls ---------- */
.qt-rl-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.qt-rl-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.qt-rl-meter { display: flex; align-items: center; gap: 10px; --qt-rl-chip: 40px; }
.qt-rl-meter-t { display: grid; line-height: 1.15; }
.qt-rl-meter-l { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--qt-muted, #b9b0d6); }
.qt-rl-meter-total { font-size: 20px; font-variant-numeric: tabular-nums; }
.qt-rl-meter-limit { font-size: 12px; color: var(--qt-muted, #b9b0d6); }

.qt-rl-btn {
  --qt-rl-b: rgba(255, 255, 255, .1);
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .16);
  cursor: pointer;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: var(--qt-ink, #f6f1ff);
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 60%), var(--qt-rl-b);
  transition: transform .14s ease-out, opacity .2s ease-out, filter .2s ease-out, box-shadow .2s ease-out;
}
.qt-rl-btn:hover:not(:disabled) { filter: brightness(1.15); }
.qt-rl-btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.qt-rl-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.qt-rl-btn:disabled { opacity: .4; cursor: default; }
.qt-rl-btn--spin {
  --qt-rl-b: var(--qt-accent, #ff4a5f);
  min-height: 60px;
  min-width: 170px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0) 52%),
    var(--qt-rl-b);
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, .25),
    inset 0 1px 0 rgba(255, 255, 255, .6),
    0 8px 28px color-mix(in srgb, var(--qt-accent, #ff4a5f) 60%, transparent);
}
.qt-rl-btn--spin:hover:not(:disabled) { box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .6), 0 10px 36px color-mix(in srgb, var(--qt-accent, #ff4a5f) 80%, transparent); }

.qt-rl-status {
  grid-area: status;
  margin: 0;
  justify-self: center;
  max-width: 100%;
  padding: .45em 1em;
  border-radius: 999px;
  background: var(--qt-panel, rgba(16, 10, 30, .72));
  border: 1px solid var(--qt-line, rgba(255, 255, 255, .12));
  font-size: 14px;
  text-align: center;
}

/* ---------- wide: wheel left, board right ---------- */
@container (min-width: 820px) {
  .qt-rl-grid {
    grid-template-columns: minmax(250px, 300px) 1fr;
    grid-template-areas: "wheel board" "wheel controls" "status status";
    align-items: stretch;
  }
  .qt-rl-wheelpanel { grid-template-columns: 1fr; align-content: center; }
  .qt-rl-boardpanel { display: grid; align-content: center; }
  .qt-rl-board { --qt-rl-chip: 30px; --qt-rl-hs: 20px; grid-template-rows: repeat(3, 68px) 50px 50px; }
}

/* ---------- narrow: vertical board ---------- */
@container (max-width: 600px) {
  .qt-rl-board {
    --qt-rl-hs: 16px;
    --qt-rl-chip: 26px;
    grid-template-columns: .85fr .85fr repeat(3, minmax(0, 1.25fr));
    grid-template-rows: 40px repeat(12, 31px) 36px;
  }
  .qt-rl-cell,
  .qt-rl-fill { grid-column: var(--vc); grid-row: var(--vr); }
  .qt-rl-cell--num.is-green { border-radius: 8px 8px 0 0; }
  .qt-rl-cell--dz .qt-rl-cell-n,
  .qt-rl-cell--ev .qt-rl-cell-n { writing-mode: vertical-rl; transform: rotate(180deg); }
  .qt-rl-diamond { width: 60%; aspect-ratio: .62; max-width: none; }
  /* edge mapping: horizontal right -> bottom, top -> right, bottom -> left */
  .qt-rl-hs--r { left: 50%; top: 100%; }
  .qt-rl-hs--t { left: 100%; top: 50%; }
  .qt-rl-hs--tr { left: 100%; top: 100%; }
  .qt-rl-hs--b { left: 0; top: 50%; }
  .qt-rl-hs--br { left: 0; top: 100%; }
  .qt-rl-hs > .qt-rl-chip--placed { --qt-rl-chip: 22px; }
  .qt-rl-controls { grid-template-columns: 1fr auto; }
  .qt-rl-tools { grid-column: 1 / -1; }
  .qt-rl-tools .qt-rl-btn { flex: 1 1 auto; }
  .qt-rl-btn--spin { min-width: 0; width: 100%; padding: 0 18px; }
  .qt-rl-controls {
    position: sticky;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 6;
  }
  .qt-rl-result { flex-direction: column; align-items: flex-start; gap: 6px; }
  .qt-rl-hist-n { width: 26px; height: 26px; font-size: 12px; border-radius: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .qt-rl *,
  .qt-rl *::before,
  .qt-rl *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
