:root {
  --bg-1: #fff7d7;
  --bg-2: #dff8ff;
  --ink: #22203a;
  --muted: #706b91;
  --card: rgba(255, 255, 255, 0.74);
  --card-strong: rgba(255, 255, 255, 0.94);
  --p1: #ff7f7f;
  --p2: #6d8dff;
  --accent: #6f5cff;
  --accent-2: #ffce4f;
  --good: #23c48e;
  --danger: #ff5b75;
  --shadow: 0 18px 55px rgba(55, 35, 115, 0.18);
  --radius: 24px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 206, 79, 0.56), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(111, 92, 255, 0.22), transparent 30%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  touch-action: none;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100vw, 1280px);
  height: 100vh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.topbar,
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #ffffff, #fff0b8);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.07), 0 12px 25px rgba(255, 174, 66, 0.25);
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.centered { text-align: center; }

h1,
h2,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
}

.score-card {
  min-width: 92px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.62);
  border: 2px solid transparent;
}

.score-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-card strong {
  font-size: 22px;
  line-height: 1;
}

.score-card.is-active:first-child { border-color: var(--p1); }
.score-card.is-active:last-child { border-color: var(--p2); }

.turn-pill,
.info-chip {
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(34, 32, 58, 0.08);
  color: var(--ink);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 900;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  justify-content: flex-end;
}

.small-btn,
.primary-btn {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(111, 92, 255, 0.25);
}

.small-btn {
  padding: 10px 12px;
  font-size: 13px;
}

.small-btn.ghost {
  background: rgba(34, 32, 58, 0.1);
  color: var(--ink);
  box-shadow: none;
}

.primary-btn {
  width: 100%;
  margin-top: 8px;
  padding: 15px 18px;
  font-size: 17px;
}

.stage-wrap {
  position: relative;
  min-height: 0;
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #9de8be;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: transparent;
  touch-action: none;
}

.message-toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 10px 15px;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  backdrop-filter: blur(10px);
  pointer-events: none;
  text-align: center;
}

.message-toast[data-tone="good"] {
  background: rgba(226, 255, 241, 0.94);
  color: #126247;
}

.message-toast[data-tone="danger"] {
  background: rgba(255, 231, 236, 0.94);
  color: #9b2440;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(42, 34, 85, .25), rgba(42, 34, 85, .42));
  backdrop-filter: blur(8px);
  z-index: 10;
}

.overlay.hidden { display: none; }

.panel {
  width: min(540px, 100%);
  border-radius: 30px;
  background: var(--card-strong);
  padding: 24px;
  box-shadow: 0 30px 90px rgba(34, 32, 58, 0.28);
  text-align: center;
}

.panel.compact { width: min(420px, 100%); }

.panel p {
  color: var(--muted);
  line-height: 1.5;
}

.mascot-bubble {
  width: 74px;
  height: 74px;
  margin: -58px auto 14px;
  display: grid;
  place-items: center;
  border: 5px solid #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe177, #ff8ca1);
  color: #3b2856;
  font-weight: 1000;
  box-shadow: 0 16px 36px rgba(255, 122, 166, 0.35);
}

.mascot-bubble.winner {
  background: linear-gradient(145deg, #baffd8, #8ec1ff);
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.rule-grid div {
  min-height: 98px;
  border-radius: 22px;
  background: rgba(111, 92, 255, 0.08);
  padding: 13px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.rule-grid strong {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
}

.rule-grid span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
}

.bottombar {
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px;
}

.info-chip {
  padding: 8px 12px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .game-shell { gap: 7px; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }
  .brand-lockup { min-width: 0; }
  .brand-mark { width: 38px; height: 38px; font-size: 20px; border-radius: 14px; }
  .scoreboard { grid-column: 1 / -1; order: 3; width: 100%; }
  .actions { min-width: 0; }
  .score-card { min-width: 0; flex: 1; padding: 8px 10px; }
  .turn-pill { padding: 9px 10px; font-size: 12px; }
  .stage-wrap { border-radius: 24px; }
  .message-toast { top: 10px; font-size: 12px; }
  .panel { padding: 22px 16px; border-radius: 26px; }
  .rule-grid { grid-template-columns: repeat(2, 1fr); }
  .rule-grid div { min-height: auto; grid-template-columns: 38px 1fr; text-align: left; align-items: center; }
  .panel p { font-size: 14px; }
  .rule-grid strong { margin: 0; }
  .bottombar { display: none; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .topbar { padding: 7px; border-radius: 18px; }
  .brand-mark { width: 34px; height: 34px; }
  h1 { font-size: 19px; }
  .eyebrow { display: none; }
  .score-card { padding: 6px 10px; }
  .small-btn { padding: 8px 10px; }
  .bottombar { display: none; }
}
