:root {
  --bg: #0c1023;
  --bg-deep: #080b18;
  --surface: #151a34;
  --surface-soft: #1b2140;
  --line: rgba(196, 204, 255, 0.13);
  --line-bright: rgba(196, 204, 255, 0.25);
  --text: #f6f6ff;
  --muted: #969cbd;
  --accent: #a9f36b;
  --accent-dark: #273d20;
  --pink: #ff7ca8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
  font-family: "Gowun Dodum", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(93, 104, 203, 0.19), transparent 32rem),
    radial-gradient(circle at 90% 100%, rgba(154, 243, 107, 0.07), transparent 28rem),
    var(--bg);
}

button { font: inherit; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.app-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 22px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 42px; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line-bright); border-radius: 12px; color: var(--accent); font-family: "Space Grotesk", sans-serif; font-size: 26px; box-shadow: inset 0 0 20px rgba(169, 243, 107, .08); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-family: "Space Grotesk", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .17em; line-height: 1; }
h1, h2, p { margin-top: 0; }
h1 { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 25px; letter-spacing: -.04em; }
.topbar-note { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.game-layout { display: grid; grid-template-columns: 220px minmax(320px, 360px) 220px; align-items: start; justify-content: center; gap: 34px; }
.side-panel { display: grid; gap: 18px; }
.info-card, .tip-card { border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(29, 35, 69, .86), rgba(17, 21, 44, .86)); box-shadow: var(--shadow); }
.info-card { padding: 22px; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.05em; }
.compact-heading { margin-bottom: 18px; }
.next-card { min-height: 250px; }
.next-preview-wrap { display: grid; place-items: center; min-height: 125px; margin: 12px 0 8px; border: 1px dashed var(--line-bright); border-radius: 14px; background: rgba(5, 8, 23, .28); }
#next-canvas { width: 160px; max-width: 100%; height: auto; }
.hint-text { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.stats-card { padding-bottom: 16px; }
.stats-list { margin: 0; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.stat-row dt, .stat-row dd { margin: 0; }
.stat-row dd { color: var(--text); font-family: "Space Grotesk", sans-serif; font-weight: 600; }
.featured-stat dd { color: var(--accent); font-size: 23px; letter-spacing: -.05em; }
.help-button { margin-top: -2px; }

.board-column { display: flex; justify-content: center; }
.board-frame { width: 100%; padding: 15px; border: 1px solid var(--line-bright); border-radius: 22px; background: #10142b; box-shadow: 0 30px 90px rgba(0, 0, 0, .44); }
.board-meta, .board-footer { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-family: "Space Grotesk", sans-serif; font-size: 10px; letter-spacing: .08em; }
.board-meta { padding: 0 3px 11px; }
.status-label { color: var(--accent); font-weight: 700; }
.board-size { color: #656d93; }
.canvas-wrap { position: relative; overflow: hidden; border: 1px solid rgba(255, 255, 255, .08); border-radius: 11px; background: #090c1d; }
#game-board { display: block; width: 100%; height: auto; aspect-ratio: 1 / 2; }
.board-footer { flex-wrap: wrap; gap: 8px 12px; padding: 13px 3px 2px; font-family: "Gowun Dodum", sans-serif; font-size: 11px; letter-spacing: 0; }
kbd { display: inline-grid; min-width: 24px; height: 24px; padding: 0 6px; place-items: center; border: 1px solid var(--line-bright); border-bottom-width: 2px; border-radius: 6px; color: var(--text); background: rgba(255, 255, 255, .06); font-family: "Space Grotesk", sans-serif; font-size: 10px; line-height: 1; }
.board-footer kbd { min-width: 21px; height: 20px; padding: 0 4px; margin-right: 3px; color: var(--muted); font-size: 9px; }

.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(8, 11, 28, .78); backdrop-filter: blur(7px); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.game-overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay-content { width: min(100%, 270px); padding: 25px 18px; text-align: center; border: 1px solid var(--line-bright); border-radius: 17px; background: rgba(23, 28, 57, .91); box-shadow: 0 20px 45px rgba(0, 0, 0, .35); }
.overlay-icon { display: block; margin-bottom: 13px; color: var(--accent); font-size: 28px; line-height: 1; }
.overlay-content h2 { margin: 0 0 10px; font-size: 23px; letter-spacing: -.07em; }
.overlay-content p:not(.eyebrow) { margin: 0 0 21px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.primary-button, .secondary-button { border-radius: 9px; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.primary-button { width: 100%; padding: 13px 16px; border: 1px solid var(--accent); color: #111a0e; background: var(--accent); font-size: 14px; font-weight: 700; }
.primary-button span { margin-left: 8px; font-family: "Space Grotesk", sans-serif; }
.primary-button:hover { transform: translateY(-2px); background: #c2ff91; }
.secondary-button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1px solid var(--line-bright); color: var(--text); background: rgba(255, 255, 255, .04); font-size: 13px; }
.secondary-button:hover { border-color: var(--accent); background: rgba(169, 243, 107, .08); }
.help-button span { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--muted); border-radius: 50%; color: var(--muted); font-family: "Space Grotesk", sans-serif; font-size: 11px; }

.controls-card { padding-bottom: 12px; }
.controls-list { display: grid; gap: 13px; margin: 21px 0 0; padding: 0; list-style: none; }
.controls-list li { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: 12px; }
.key-group { display: flex; gap: 4px; }
.key-group kbd { min-width: 27px; }
.tip-card { display: flex; gap: 12px; padding: 18px 16px; border-color: rgba(169, 243, 107, .22); background: linear-gradient(135deg, rgba(46, 69, 36, .32), rgba(22, 29, 54, .7)); }
.tip-icon { color: var(--accent); font-size: 17px; }
.tip-card p:not(.eyebrow) { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.tip-card strong { color: var(--text); }

.site-footer { display: flex; justify-content: space-between; margin-top: 30px; color: #5f668b; font-family: "Space Grotesk", sans-serif; font-size: 9px; letter-spacing: .13em; }

.help-dialog { width: min(420px, calc(100% - 36px)); padding: 0; border: 1px solid var(--line-bright); border-radius: 18px; color: var(--text); background: var(--surface); box-shadow: 0 30px 100px rgba(0, 0, 0, .65); }
.help-dialog::backdrop { background: rgba(4, 6, 17, .74); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; padding: 23px 24px 17px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; font-size: 22px; line-height: 1; cursor: pointer; }
.icon-button:hover { color: var(--text); border-color: var(--accent); }
.dialog-body { padding: 20px 24px 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.dialog-body > p:first-child { margin: 0 0 18px; }
.dialog-control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 19px; }
.dialog-control-grid > div { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; }
.dialog-control-grid strong { width: 100%; margin-top: 3px; color: var(--text); font-size: 11px; font-weight: 400; }
.dialog-note { margin: 0 !important; padding-top: 15px; border-top: 1px solid var(--line); font-size: 12px; }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 190px minmax(300px, 340px) 190px; gap: 18px; }
  .info-card { padding: 18px; }
  .app-shell { width: min(100% - 30px, 800px); }
}

@media (max-width: 730px) {
  .app-shell { width: min(100% - 28px, 420px); padding-top: 20px; }
  .topbar { margin-bottom: 24px; }
  .topbar-note { display: none; }
  .game-layout { grid-template-columns: 1fr; gap: 14px; }
  .board-column { grid-row: 1; }
  .left-panel { grid-row: 2; grid-template-columns: 1fr 1fr; align-items: stretch; }
  .left-panel .next-card { grid-row: span 2; }
  .left-panel .help-button { grid-column: 2; }
  .right-panel { grid-row: 3; grid-template-columns: 1fr 1fr; }
  .controls-card { grid-column: span 2; }
  .controls-list { grid-template-columns: repeat(3, 1fr); }
  .controls-list li { display: grid; justify-items: center; text-align: center; }
  .controls-list li:nth-child(4), .controls-list li:nth-child(5) { display: flex; justify-content: center; }
  .tip-card { align-items: center; }
  .site-footer { margin-top: 22px; }
}

@media (max-width: 390px) {
  .app-shell { width: calc(100% - 18px); }
  .board-frame { padding: 10px; border-radius: 16px; }
  .board-footer { font-size: 10px; }
  .left-panel, .right-panel { grid-template-columns: 1fr; }
  .left-panel .next-card, .left-panel .help-button, .controls-card { grid-column: auto; grid-row: auto; }
  .controls-list { grid-template-columns: repeat(2, 1fr); }
  .controls-list li:nth-child(4), .controls-list li:nth-child(5) { display: grid; justify-items: center; }
  .tip-card { grid-column: auto; }
}
