@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Space+Mono:wght@400;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #070910;
  --panel: rgba(17, 20, 31, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --muted: #767c90;
  --text: #f7f8fc;
  --cyan: #2df5ff;
  --purple: #8c5bff;
  --pink: #ff4fc8;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(72, 52, 138, 0.14), transparent 31rem),
    linear-gradient(180deg, #0a0c14 0%, #06070c 100%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, black, transparent 86%);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.ambient { position: fixed; width: 22rem; height: 22rem; border-radius: 50%; filter: blur(110px); pointer-events: none; opacity: .08; }
.ambient-one { left: -12rem; top: 28%; background: var(--cyan); }
.ambient-two { right: -12rem; top: 18%; background: var(--purple); }

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

.topbar { height: 94px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 14px; align-items: center; color: white; text-decoration: none; font-size: 14px; font-weight: 700; letter-spacing: .19em; }
.brand b { color: var(--cyan); }
.brand-mark, .overlay-logo { width: 29px; height: 29px; position: relative; display: block; transform: rotate(-2deg); }
.brand-mark i, .overlay-logo i { position: absolute; width: 9px; height: 9px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 9px rgba(45,245,255,.6); }
.brand-mark i:nth-child(1), .overlay-logo i:nth-child(1) { left: 0; top: 10px; }
.brand-mark i:nth-child(2), .overlay-logo i:nth-child(2) { left: 10px; top: 10px; }
.brand-mark i:nth-child(3), .overlay-logo i:nth-child(3) { left: 10px; top: 0; background: var(--purple); box-shadow: 0 0 9px rgba(140,91,255,.7); }
.brand-mark i:nth-child(4), .overlay-logo i:nth-child(4) { left: 20px; top: 0; background: var(--pink); box-shadow: 0 0 9px rgba(255,79,200,.7); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.status-dot { color: #8a8fa0; font-family: 'Space Mono', monospace; font-size: 9px; letter-spacing: .14em; margin-right: 7px; }
.status-dot i { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: #41ff9a; box-shadow: 0 0 8px #41ff9a; }
.icon-button { width: 36px; height: 36px; border-radius: 7px; border: 1px solid var(--line); color: #aeb2c2; background: rgba(255,255,255,.025); cursor: pointer; transition: .2s ease; }
.icon-button:hover { color: white; border-color: rgba(45,245,255,.36); background: rgba(45,245,255,.07); }

.game-layout { min-height: 716px; display: grid; grid-template-columns: 210px 356px 210px; justify-content: center; align-items: center; gap: 46px; padding: 40px 0; }
.panel { background: linear-gradient(145deg, rgba(25,28,42,.78), rgba(12,14,23,.88)); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 55px rgba(0,0,0,.22); }
.stats-panel { padding: 24px; }
.eyebrow { font-family: 'Space Mono', monospace; font-size: 9px; letter-spacing: .2em; color: #73798c; font-weight: 700; margin-bottom: 20px; }
.score-block span, .stat-grid span { display: block; font-size: 9px; letter-spacing: .18em; color: #71778b; font-weight: 800; }
.score-block strong { display: block; margin-top: 4px; font-family: 'Space Mono', monospace; font-size: 34px; letter-spacing: -.08em; color: white; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 25px; }
.stat-grid > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.stat-grid strong { display: block; margin-top: 9px; font-family: 'Space Mono', monospace; font-size: 20px; }
.divider { height: 1px; margin: 25px 0 21px; background: var(--line); }
.best-row { display: flex; justify-content: space-between; align-items: center; font-family: 'Space Mono', monospace; font-size: 8px; letter-spacing: .11em; color: #747a8e; }
.best-row span i { color: #ffce46; font-style: normal; margin-right: 4px; }
.best-row strong { color: #d2d5df; font-size: 11px; }
.primary-button { width: 100%; margin-top: 23px; padding: 13px 10px; border-radius: 6px; border: 1px solid rgba(45,245,255,.28); background: rgba(45,245,255,.055); color: var(--cyan); font-size: 9px; font-weight: 800; letter-spacing: .13em; cursor: pointer; transition: .2s ease; }
.primary-button span { margin-left: 6px; font-size: 13px; }
.primary-button:hover { background: rgba(45,245,255,.13); box-shadow: 0 0 24px rgba(45,245,255,.08); }

.board-wrap { position: relative; padding: 9px; }
.board-glow { position: absolute; inset: 7% -7%; background: linear-gradient(180deg, rgba(140,91,255,.22), rgba(45,245,255,.09)); filter: blur(42px); opacity: .55; }
.board-frame { position: relative; width: 320px; height: 620px; padding: 9px; border-radius: 10px; background: #10131e; border: 1px solid rgba(255,255,255,.14); box-shadow: 0 30px 85px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.025); }
#gameCanvas { display: block; width: 300px; height: 600px; background: #080a12; border-radius: 4px; }
.game-overlay { position: absolute; inset: 9px; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; border-radius: 4px; overflow: hidden; background: radial-gradient(circle, rgba(21,24,39,.91), rgba(5,7,13,.97)); backdrop-filter: blur(8px); }
.game-overlay::before { content: ''; position: absolute; inset: 0; opacity: .25; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.025) 4px); pointer-events: none; }
.game-overlay.visible { display: flex; }
.overlay-logo { transform: scale(1.65); margin-bottom: 30px; }
.game-overlay h1 { margin: 0; font-size: 25px; letter-spacing: .14em; font-weight: 900; text-shadow: 0 0 18px rgba(255,255,255,.16); }
.game-overlay p { color: #858b9e; font-size: 11px; line-height: 1.8; margin: 18px 0 25px; }
.game-overlay button { min-width: 190px; padding: 14px 20px; border: 0; border-radius: 5px; background: linear-gradient(90deg, #754fff, #9b58ff); color: white; box-shadow: 0 8px 30px rgba(125,77,255,.3); cursor: pointer; font-size: 10px; letter-spacing: .13em; font-weight: 800; }
.game-overlay button span { margin-left: 17px; font-size: 16px; }
.game-overlay button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.game-overlay small { color: #555b6d; font-family: 'Space Mono', monospace; font-size: 7px; letter-spacing: .14em; margin-top: 15px; }
.game-overlay.compact { background: rgba(6,8,14,.92); }
.game-overlay.compact h2 { margin: 0; font-size: 24px; letter-spacing: .16em; }

.side-panel { display: grid; gap: 18px; }
.next-panel, .controls-panel { padding: 23px; }
#nextCanvas { display: block; width: 136px; height: 112px; margin: 0 auto; background: rgba(5,7,13,.5); border: 1px solid rgba(255,255,255,.055); border-radius: 5px; }
.control-row { min-height: 38px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.055); }
.control-row:last-child { border-bottom: 0; }
.control-row > span { display: flex; gap: 4px; min-width: 69px; }
.control-row b { color: #747a8e; font-size: 7px; letter-spacing: .14em; }
kbd { min-width: 23px; height: 23px; display: grid; place-items: center; padding: 0 5px; color: #9da2b2; font-family: 'Space Mono', monospace; font-size: 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 4px; background: linear-gradient(145deg, #202331, #12141e); box-shadow: 0 2px 0 #05060a; }
kbd.space { font-size: 6px; }

.touch-controls { display: none; }
footer { height: 52px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 11px; color: #4f5361; font-family: 'Space Mono', monospace; font-size: 7px; letter-spacing: .18em; }
footer span { color: var(--purple); }

@media (max-width: 920px) {
  .game-layout { grid-template-columns: 180px 340px; gap: 24px; }
  .side-panel { display: none; }
}

@media (max-width: 650px) {
  .app-shell { width: min(100% - 24px, 420px); }
  .topbar { height: 70px; }
  .status-dot { display: none; }
  .game-layout { display: flex; flex-direction: column; min-height: 0; gap: 16px; padding: 20px 0 12px; }
  .stats-panel { width: 100%; order: 2; display: grid; grid-template-columns: 1.35fr .8fr 1fr; gap: 10px; padding: 14px 16px; align-items: center; }
  .stats-panel .eyebrow, .stats-panel .divider, .best-row, .primary-button { display: none; }
  .score-block strong { font-size: 24px; }
  .stat-grid { margin: 0; }
  .stat-grid strong { font-size: 16px; }
  .board-wrap { order: 1; padding: 0; width: min(100%, 330px); }
  .board-frame { width: 100%; height: auto; aspect-ratio: 1 / 1.9375; padding: 7px; }
  #gameCanvas { width: 100%; height: 100%; }
  .game-overlay { inset: 7px; }
  .touch-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 auto 24px; width: min(100%, 380px); }
  .touch-controls button { min-height: 48px; color: #d8dbe5; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: linear-gradient(145deg, #202331, #10121b); font-weight: 800; box-shadow: 0 3px 0 #030409; touch-action: manipulation; }
  .touch-controls button:active { transform: translateY(2px); box-shadow: 0 1px 0 #030409; }
  .touch-controls .wide { grid-column: span 4; color: var(--cyan); letter-spacing: .13em; font-size: 9px; }
  footer { display: none; }
}

@media (max-height: 760px) and (min-width: 651px) {
  .topbar { height: 62px; }
  .game-layout { transform: scale(.84); transform-origin: center top; min-height: 620px; padding-top: 25px; }
  footer { display: none; }
}
