:root {
  color-scheme: dark;
  --ink: #fbfaff;
  --muted: #c9c5ef;
  --panel: rgba(31, 25, 91, .78);
  --edge: rgba(255, 255, 255, .16);
  --hot: #ff4f7b;
  --gold: #fff08a;
}

* { box-sizing: border-box; }
html { min-width: 0; background: #161542; }
body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 4%, rgba(255, 79, 123, .37), transparent 31%),
    radial-gradient(circle at 88% 18%, rgba(53, 186, 242, .32), transparent 30%),
    linear-gradient(155deg, #27205f, #12123c 68%);
}
button { font: inherit; }

.game-shell { width: min(100%, 720px); margin: 0 auto; padding: clamp(12px, 3vw, 26px); }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.eyebrow { margin: 0 0 3px; color: #bdb7ef; font-size: .7rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.05; }
h1 { font-size: clamp(1.55rem, 5.5vw, 2.45rem); letter-spacing: -.045em; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.actions button, .primary {
  min-height: 44px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 8px 20px rgba(5, 3, 31, .22);
  cursor: pointer;
  font-weight: 850;
}
.actions button:hover { background: rgba(255, 255, 255, .18); transform: translateY(-1px); }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.hud div { min-width: 0; padding: 9px 5px; border: 1px solid var(--edge); border-radius: 14px; text-align: center; background: var(--panel); box-shadow: 0 8px 22px rgba(5, 3, 31, .18); }
.hud span { display: block; color: var(--muted); font-size: .67rem; font-weight: 700; }
.hud strong { display: block; overflow: hidden; font-size: clamp(.88rem, 3.6vw, 1.15rem); text-overflow: ellipsis; white-space: nowrap; }
.status { min-height: 1.4em; margin: 0 0 8px; color: #e5e2ff; font-size: .88rem; font-weight: 750; text-align: center; }
.status[data-mood="good"] { color: #8fffc6; }
.status[data-mood="warning"] { color: #ffc0d0; }

.canvas-wrap { position: relative; width: min(100%, 490px); margin: 0 auto; }
canvas { display: block; width: 100%; height: auto; border: 1px solid rgba(255, 255, 255, .2); border-radius: 26px; box-shadow: 0 24px 55px rgba(5, 3, 35, .38); touch-action: none; user-select: none; }
.overlay { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; padding: 18px; border-radius: 26px; background: rgba(9, 7, 42, .72); backdrop-filter: blur(5px); }
.overlay[hidden] { display: none; pointer-events: none; }
.overlay-card { width: min(100%, 345px); padding: 27px 24px; border: 1px solid rgba(255,255,255,.25); border-radius: 24px; text-align: center; background: linear-gradient(145deg, #4532a0, #24216b); box-shadow: 0 24px 60px rgba(0,0,0,.38); }
.overlay-card h2 { font-size: clamp(1.65rem, 7vw, 2.25rem); }
.overlay-card > p:not(.eyebrow) { color: #dedaff; line-height: 1.55; }
.primary { width: 100%; border: 0; color: #24124b; background: linear-gradient(135deg, var(--gold), #ffb85c); font-size: 1.04rem; }
.primary:hover { filter: brightness(1.08); transform: translateY(-2px); }

.tips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 13px auto 0; color: var(--muted); font-size: .82rem; }
.tips p { margin: 0; padding: 10px 12px; border: 1px solid var(--edge); border-radius: 13px; background: rgba(255,255,255,.07); }

@media (max-width: 520px) {
  .game-shell { padding: 10px 8px 18px; }
  .game-header { align-items: flex-start; }
  .actions { gap: 4px; }
  .actions button { min-height: 40px; padding: 7px 9px; font-size: .7rem; }
  .hud { gap: 4px; }
  .hud div { padding: 7px 2px; border-radius: 10px; }
  .hud span { font-size: .57rem; }
  .tips { grid-template-columns: 1fr; }
}

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