:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b26;
  --panel-2: #1b2331;
  --line: #2a3444;
  --text: #e9eef5;
  --muted: #93a1b5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -10%, #1d3a5f 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 0%, #3a2350 0%, transparent 55%),
    var(--bg);
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.hero { text-align: center; margin-bottom: 28px; }

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 12px;
  font-weight: 700;
  color: #7fb0ff;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 58px);
  letter-spacing: -.03em;
  background: linear-gradient(90deg, #8ec5ff, #c8a6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  max-width: 640px;
  margin: 12px auto 18px;
  color: var(--muted);
  line-height: 1.6;
}

.fact {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.03);
  font-size: 14px;
  color: var(--muted);
}
.fact strong { color: var(--text); }

.prompt { text-align: center; color: var(--muted); margin: 0 0 26px; font-size: 14px; }

/* ---------- Result card ---------- */

.result {
  --accent: #7fb0ff;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 28px;
  border: 1px solid var(--accent);
  border-radius: 18px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 15%, var(--panel)), var(--panel));
  box-shadow: 0 18px 44px rgba(0,0,0,.3);
}
.result.pirate  { --accent: #ffd166; }
.result.gizmo-a { --accent: #67e8f9; }
.result.gizmo-b { --accent: #a7f3d0; }
.result.gizmo-c { --accent: #c4b5fd; }
.result.empty   { --accent: #6b7688; }

.result-icon {
  flex: none;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  font-size: 42px;
  line-height: 1;
  border-radius: 16px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, #0d1117);
}

.result-copy { flex: 1; min-width: 0; }
.result-label {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.result h2 { margin: 0 0 6px; font-size: clamp(22px, 4vw, 30px); }
.result-detail { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.continue {
  flex: none;
  border: 0;
  border-radius: 12px;
  padding: 14px 24px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  color: #0b1220;
  background: linear-gradient(90deg, #8ec5ff, #c8a6ff);
  box-shadow: 0 8px 20px rgba(110,168,254,.25);
}
.continue:hover { filter: brightness(1.08); }
.continue:active { transform: translateY(1px); }

/* ---------- Board ---------- */

.board-section { margin-top: 34px; }
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.board-section h2 { margin: 0; font-size: 20px; }
.hint { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 6px;
}
.cell-form { margin: 0; }

.chest {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0;
  font: inherit;
  color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.chest .emoji { font-size: clamp(14px, 2vw, 22px); line-height: 1; }
.chest .idx {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chest.closed {
  cursor: pointer;
  background: linear-gradient(160deg, #2b3749, #1a2331);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.chest.closed:hover {
  transform: translateY(-2px);
  border-color: #7fb0ff;
  box-shadow: 0 6px 18px rgba(110,168,254,.25);
  z-index: 1;
}

.chest.locked {
  cursor: default;
  opacity: .55;
  background: #151b26;
}

.chest.opened {
  background: #121823;
  border-color: var(--accent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--accent) 18%, transparent);
}
.chest.opened.pirate   { --accent: #ffd166; }
.chest.opened.gizmo-a  { --accent: #67e8f9; }
.chest.opened.gizmo-b  { --accent: #a7f3d0; }
.chest.opened.gizmo-c  { --accent: #c4b5fd; }
.chest.opened.empty    { --accent: #3b4658; }
.chest.opened.empty .emoji { font-size: 18px; }

footer {
  margin-top: 40px;
  text-align: center;
  color: #617086;
  font-size: 12px;
}

@media (max-width: 820px) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .wrap { padding: 24px 12px 40px; }
  .grid { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
  .chest { border-radius: 6px; }
  .chest .idx { display: none; }
  .result { flex-wrap: wrap; padding: 18px; }
  .result-icon { width: 60px; height: 60px; font-size: 34px; }
  .continue { width: 100%; }
}
