* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  touch-action: manipulation;
}

body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

#mode-select,
.meta-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  color: #f0f0f5;
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  z-index: 20;
  padding: calc(1.5rem + env(safe-area-inset-top, 0px)) calc(1.5rem + env(safe-area-inset-right, 0px)) calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(1.5rem + env(safe-area-inset-left, 0px));
  gap: 0.65rem;
}

#mode-select.hidden,
.meta-overlay.hidden {
  display: none;
}

#between-rounds,
#forgiveness-prompt {
  background: rgba(10, 10, 15, 0.97);
}

#mode-select {
  position: fixed;
}

#intro-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#mode-select .intro-content {
  position: relative;
  z-index: 2;
}

#mode-select.intro-title-phase #intro-canvas,
#mode-select.intro-done #intro-canvas {
  display: none;
}

.intro-wheel-header {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(120px * var(--layout-scale, 1));
  width: 100%;
}

.intro-wheel-display {
  display: block;
}

#mode-select.intro-playing {
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}

#mode-select.intro-playing .intro-content {
  visibility: hidden;
}

#mode-select.intro-measure .intro-content {
  visibility: visible;
  opacity: 0;
  pointer-events: none;
}

#mode-select.intro-measure .intro-reveal {
  opacity: 0;
  visibility: hidden;
}

#mode-select.intro-playing.intro-title-phase .intro-content {
  visibility: visible;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

#mode-select.intro-playing.intro-title-phase .intro-reveal {
  opacity: 0;
  visibility: hidden;
}

#mode-select.intro-done {
  background: rgba(10, 10, 15, 0.97);
  pointer-events: auto;
}

.intro-title {
  opacity: 0;
  transform: scale(0.5);
}

.intro-title.visible,
#mode-select.intro-done .intro-title {
  opacity: 1;
  transform: scale(1);
}

.intro-title.visible.pop {
  animation: titlePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes titlePop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.intro-reveal {
  opacity: 0;
  visibility: hidden;
}

#mode-select.intro-done .intro-reveal {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease 0.1s;
}

.meta-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: min(22rem, 92vw);
  padding: 1.25rem 1.5rem;
  background: #12121a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.meta-panel .title {
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f0f0f5;
  text-align: center;
}

.meta-panel .meta-stat {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  color: #f0f0f5;
  opacity: 1;
}

.meta-panel .shop-section {
  width: 100%;
  margin: 0.25rem 0;
}

.meta-panel .shop-heading {
  color: rgba(240, 240, 245, 0.78);
  opacity: 1;
}

.meta-panel .shop-note {
  color: rgba(240, 240, 245, 0.62);
  opacity: 1;
}

#mode-select .meta-panel .title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

#mode-select .subtitle {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  opacity: 0.55;
  margin-bottom: 0.5rem;
}

#mode-select .mode-best {
  font-size: clamp(0.75rem, 2.6vw, 0.9rem);
  font-weight: 400;
  opacity: 0.5;
  letter-spacing: 0.02em;
}

.meta-overlay .hint {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  opacity: 0.55;
  margin-top: 0.5rem;
}

.meta-stat {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  opacity: 0.85;
}

.shop-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  width: min(22rem, 90vw);
}

.shop-heading {
  font-size: clamp(0.85rem, 3vw, 1rem);
  opacity: 0.6;
  text-align: center;
}

.shop-note {
  font-size: clamp(0.8rem, 2.8vw, 0.95rem);
  opacity: 0.5;
  text-align: center;
}

.shop-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.meta-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f5;
  font-family: inherit;
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.meta-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.meta-btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}

.meta-btn.primary {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  margin-top: 0.5rem;
}

.meta-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.meta-btn.selected {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

#mode-select .mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

#mode-select .mode-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f5;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s;
}

#mode-select .mode-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

#mode-select .mode-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

#mode-select .mode-label {
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.mode-wheel-preview {
  display: block;
  margin: 0.15rem auto 0;
  width: calc(64px * var(--layout-scale, 1));
  height: calc(64px * var(--layout-scale, 1));
}

.coin-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  vertical-align: -0.12em;
  background: radial-gradient(circle at 35% 30%, #ffe566 0%, #f5c842 45%, #c9971a 100%);
  box-shadow:
    inset 0 -0.08em 0.12em rgba(0, 0, 0, 0.25),
    inset 0 0.06em 0.08em rgba(255, 255, 255, 0.45),
    0 0.04em 0.08em rgba(0, 0, 0, 0.35);
}

.coin-cost {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  vertical-align: middle;
}

.coin-cost-mult {
  font-variant-numeric: tabular-nums;
}

.shop-effect-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.5rem;
  padding: 0.55rem 0.65rem;
}

.shop-effect-label {
  font-size: clamp(0.8rem, 2.8vw, 0.95rem);
  line-height: 1.2;
}

.shop-effect-preview-wrap {
  position: relative;
  width: 56px;
  height: 56px;
}

.shop-effect-preview {
  display: block;
  width: 56px;
  height: 56px;
}

.shop-disabled-x {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  align-items: center;
  justify-content: center;
}

.shop-disabled-x::before,
.shop-disabled-x::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(88%, 90%, 92%);
  height: clamp(7px, 0.55rem, 8px);
  margin-top: calc(clamp(7px, 0.55rem, 8px) / -2);
  margin-left: calc(clamp(88%, 90%, 92%) / -2);
  background: #ff3b30;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 1px 3px rgba(0, 0, 0, 0.45);
}

.shop-disabled-x::before {
  transform: rotate(45deg);
}

.shop-disabled-x::after {
  transform: rotate(-45deg);
}

.shop-effect-btn.is-disabled-choice .shop-disabled-x {
  display: flex;
}

.negate-btn-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  line-height: 1.25;
}

#game-over-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  color: #f0f0f5;
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  cursor: pointer;
  z-index: 20;
  padding: calc(1.5rem + env(safe-area-inset-top, 0px)) calc(1.5rem + env(safe-area-inset-right, 0px)) calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(1.5rem + env(safe-area-inset-left, 0px));
}

#game-over-screen .meta-panel .title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

#game-over-screen .hint {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  opacity: 0.55;
  margin-top: 0.5rem;
}

#game-over-screen.is-navigating {
  opacity: 0.6;
  pointer-events: none;
}

#game-over-screen.is-navigating .hint::after {
  content: ' Loading…';
}

#demo-end-card {
  cursor: default;
}

#demo-end-card .meta-panel .title {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

#demo-end-card .meta-btn {
  width: 100%;
}

.privacy-link {
  position: fixed;
  right: calc(0.75rem + env(safe-area-inset-right, 0px));
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: clamp(0.65rem, 2.2vw, 0.75rem);
  color: #f0f0f5;
  opacity: 0.35;
  text-decoration: none;
  pointer-events: auto;
  transition: opacity 0.15s;
}

.privacy-link:hover,
.privacy-link:focus-visible {
  opacity: 0.65;
  outline: none;
}

body.privacy-page {
  overflow: auto;
  background: #0a0a0f;
  color: #f0f0f5;
  font-family: system-ui, -apple-system, sans-serif;
  padding: calc(1.5rem + env(safe-area-inset-top, 0px)) calc(1.5rem + env(safe-area-inset-right, 0px)) calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(1.5rem + env(safe-area-inset-left, 0px));
}

.privacy-content {
  max-width: 36rem;
  margin: 0 auto;
  line-height: 1.6;
}

.privacy-content h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.privacy-updated {
  font-size: 0.875rem;
  opacity: 0.5;
  margin-bottom: 2rem;
}

.privacy-content section {
  margin-bottom: 1.75rem;
}

.privacy-content h2 {
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: rgba(240, 240, 245, 0.9);
}

.privacy-content p {
  font-size: clamp(0.9rem, 3vw, 1rem);
  color: rgba(240, 240, 245, 0.78);
}

.privacy-content a {
  color: rgba(240, 240, 245, 0.9);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.privacy-content a:hover {
  color: #f0f0f5;
}

.privacy-back {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.privacy-back a {
  font-size: 0.9rem;
  opacity: 0.7;
  text-decoration: none;
}

.privacy-back a:hover {
  opacity: 1;
}