:root {
  --ink: #12110F;
  --bg: #F4F0E7;
  --accent: #FACD08;
  --accent-strong: #C9A206;
  --text-muted: #6F6A61;
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: var(--font-sans);
  color: var(--ink);
  background: #0d1420;
  user-select: none;
  -webkit-user-select: none;
}

#game-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(180deg, #ffb677 0%, #ff8a5b 45%, #a37e5a 75%, #4c3c2e 100%);
  touch-action: manipulation;
}

/* HUD */
#ui-hud {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 5;
  color: #fff;
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hud-brand-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.hud-brand {
  display: flex;
  align-items: center;
}

.hud-brand img {
  height: 22px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.hud-score-line {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  padding-left: 4px;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.hud-score-sep {
  color: rgba(244, 240, 231, 0.5);
  font-size: 14px;
  font-weight: 400;
}

#hud-target-value {
  color: rgba(244, 240, 231, 0.7);
  font-size: 14px;
  font-weight: 500;
}

.hud-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hud-mute {
  pointer-events: auto;
  border: 0;
  background: rgba(18, 17, 15, 0.55);
  color: #fff;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease;
}
.hud-mute:active { transform: scale(0.92); }

.hud-lang {
  pointer-events: auto;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(18, 17, 15, 0.55);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hud-lang-btn {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 28px;
  transition: color 0.15s ease, background 0.15s ease;
}
.hud-lang-btn:hover { color: #fff; }
.hud-lang-btn.is-current {
  color: var(--ink);
  background: var(--accent);
}

.overlay-lang {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  margin: 0 auto 16px;
}
.overlay-lang-btn {
  border: 0;
  background: transparent;
  color: rgba(244, 240, 231, 0.6);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 32px;
  transition: color 0.15s ease, background 0.15s ease;
}
.overlay-lang-btn:hover { color: #fff; }
.overlay-lang-btn.is-current {
  color: var(--ink);
  background: var(--accent);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 12, 12, 0.55);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  animation: overlay-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.overlay.hidden {
  display: none;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-inner {
  max-width: 380px;
  width: 100%;
  background: #12110F;
  color: #fff;
  border-radius: 24px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  animation: card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.brand img { height: 28px; width: auto; }

.title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
}

.subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: rgba(244, 240, 231, 0.72);
  line-height: 1.45;
}

.subtitle b { color: var(--accent); font-weight: 700; }

.hints {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 13px;
  color: rgba(244, 240, 231, 0.65);
}

.hints .key {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(250, 205, 8, 0.16);
  color: var(--accent);
  margin-right: 6px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  width: 100%;
  max-width: 240px;
}

.btn-primary:active { transform: scale(0.97); }

.foot {
  margin: 16px 0 0;
  font-size: 11px;
  color: rgba(244, 240, 231, 0.5);
  line-height: 1.5;
}

/* Rotate overlay — only for landscape phones */
.overlay-rotate {
  display: none !important;
}
@media (orientation: landscape) and (max-height: 500px) {
  .overlay-rotate.hidden,
  .overlay-rotate {
    display: flex !important;
    z-index: 100;
  }
}
.rotate-icon {
  animation: rotate-pulse 1.6s ease-in-out infinite;
}
@keyframes rotate-pulse {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(90deg); }
  60% { transform: rotate(90deg); }
  100% { transform: rotate(0deg); }
}

.overlay-links {
  margin: 14px 0 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.overlay-links a {
  color: rgba(244, 240, 231, 0.75);
  text-decoration: none;
  border-bottom: 1px dashed rgba(244, 240, 231, 0.3);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.overlay-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.overlay-sep {
  color: rgba(244, 240, 231, 0.3);
}

.end-icon { font-size: 42px; margin-bottom: 8px; line-height: 1; }

.prize-card {
  background: linear-gradient(180deg, rgba(250, 205, 8, 0.12), rgba(250, 205, 8, 0.03));
  border: 1px solid rgba(250, 205, 8, 0.35);
  border-radius: 16px;
  padding: 18px 16px;
  margin: 4px 0 20px;
}

.prize-card.hidden { display: none; }

.prize-media {
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 4 / 3;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(250, 205, 8, 0.25);
}

.prize-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.prize-media img[src=""],
.prize-media img:not([src]) {
  display: none;
}

.prize-media-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: rgba(255, 255, 255, 0.4);
}

.prize-media img[src]:not([src=""]) ~ .prize-media-fallback {
  display: none;
}

.prize-icon { font-size: 32px; margin-bottom: 4px; }

.prize-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.prize-desc {
  font-size: 13px;
  color: rgba(244, 240, 231, 0.7);
  margin-bottom: 14px;
}

.coupon-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244, 240, 231, 0.55);
  margin-bottom: 6px;
}

.coupon-code {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  padding: 10px 14px;
  border: 1.5px dashed rgba(250, 205, 8, 0.5);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  display: inline-block;
  margin-bottom: 8px;
}

.coupon-hint {
  font-size: 11px;
  color: rgba(244, 240, 231, 0.55);
}

.coupon-hint span { color: var(--accent); font-family: var(--font-mono); }

.hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: rgba(244, 240, 231, 0.6);
}

.hint.hidden { display: none; }
