:root {
  --bg: #120a26;
  --bg2: #24124a;
  --accent: #ffcf4a;
  --accent2: #ff5f8d;
  --text: #f6f2ff;
  --muted: #b7a9d8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #07040f;
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.game-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 0%, #2a1358 0%, #120a26 55%, #07040f 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 420 / 740));
  height: min(100vh, calc(100vw * 740 / 420));
  max-width: 480px;
  max-height: 900px;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: #160d2e;
  box-shadow:
    0 0 0 2px rgba(255, 207, 74, 0.25),
    0 18px 60px rgba(0, 0, 0, 0.65),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(12, 6, 28, 0.82), rgba(12, 6, 28, 0.95));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.screen--visible {
  display: flex;
}

.title {
  margin: 0;
  font-size: clamp(34px, 11vw, 58px);
  line-height: 0.95;
  letter-spacing: 2px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(255, 207, 74, 0.5), 0 5px 0 #7a3a00;
}

.title span {
  display: block;
  color: var(--accent2);
  text-shadow: 0 0 26px rgba(255, 95, 141, 0.55), 0 5px 0 #5b0d2c;
}

.subtitle {
  margin: 0;
  max-width: 300px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 13px;
  color: rgba(183, 169, 216, 0.75);
}

.result-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--accent);
}

.result-score {
  font-size: 56px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 207, 74, 0.55);
  font-variant-numeric: tabular-nums;
}

.result-best {
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.breakdown {
  list-style: none;
  margin: 0;
  padding: 0 2px 0 0;
  width: 100%;
  max-width: 300px;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.breakdown li {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.breakdown li .label {
  color: var(--muted);
}

.breakdown li.bust {
  background: rgba(255, 95, 141, 0.16);
  color: #ffc0d1;
}

.breakdown li.bust .label {
  color: #ff9bbb;
}

.breakdown li.win {
  background: rgba(255, 207, 74, 0.14);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 26px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 15px;
  color: #2a1600;
  background: linear-gradient(180deg, #ffe27a, #ffb62e);
  box-shadow: 0 6px 0 #8a4b00, 0 10px 24px rgba(255, 182, 46, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #8a4b00, 0 6px 14px rgba(255, 182, 46, 0.3);
}

.btn--big {
  font-size: 19px;
  padding: 15px 42px;
}

.btn--danger {
  color: #fff;
  background: linear-gradient(180deg, #ff89ab, #e93e72);
  box-shadow: 0 6px 0 #741332, 0 10px 24px rgba(233, 62, 114, 0.35);
}

.btn--danger:active {
  box-shadow: 0 2px 0 #741332, 0 6px 14px rgba(233, 62, 114, 0.3);
}

.btn--ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.btn[hidden] {
  display: none;
}

@media (max-height: 520px) {
  .screen {
    gap: 10px;
    padding: 16px;
  }
  .result-score {
    font-size: 40px;
  }
}
