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

:root {
  color-scheme: dark;
  --page: #101411;
  --panel: #171d18;
  --panel-raised: #1d251f;
  --line: #2b362d;
  --text: #f0f5ee;
  --muted: #98a69a;
  --accent: #b6f36b;
  --accent-strong: #9ce64a;
  --accent-ink: #17210e;
  --danger: #ff8178;
  --shadow: 0 24px 70px rgba(0, 0, 0, .25);
  font-family: 'Manrope', system-ui, sans-serif;
}
body {
  color: var(--text) !important;
}
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.snake-app {
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0px 0 24px;
}
.game-shell { width: 100%; }
.game-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 86px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: color .18s ease;
}
.back-link:hover { color: var(--text); }
.back-arrow { font-size: 20px; line-height: 1; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--accent);
  background: rgba(182, 243, 107, .1);
  border: 1px solid rgba(182, 243, 107, .2);
  border-radius: 15px;
}
.brand-mark svg { width: 30px; height: 30px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: .15em;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; font-weight: 800; letter-spacing: -.05em; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #c7d1c7;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(182, 243, 107, .45); }
.status-pill[data-state="playing"] .status-dot { animation: pulse 1.3s ease-in-out infinite; }
.status-pill[data-state="paused"] .status-dot { background: #ffc86b; box-shadow: none; }
.status-pill[data-state="over"] .status-dot { background: var(--danger); box-shadow: none; }
.score-strip { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.score-card {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(29, 37, 31, .95), rgba(22, 28, 23, .95));
}
.score-label { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .13em; }
.score-card strong { font-family: 'DM Mono', monospace; font-size: 24px; line-height: 1; font-weight: 500; letter-spacing: -.04em; }
.best-card strong { color: var(--accent); }
.level-card strong { font-family: 'Manrope', sans-serif; font-size: 17px; letter-spacing: -.03em; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .75fr); align-items: start; gap: 18px; }
.board-column { min-width: 0; }
.board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #344135;
  border-radius: 20px;
  background: #141b15;
  box-shadow: var(--shadow);
}
#game-board { display: block; width: 100%; height: 100%; touch-action: none; }
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(12, 17, 13, .72);
  backdrop-filter: blur(7px);
  transition: opacity .22s ease, visibility .22s ease;
}
.game-overlay.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay-content { width: min(100%, 340px); text-align: center; animation: rise-in .32s ease both; }
.overlay-icon {
  display: inline-grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin-bottom: 22px;
  color: var(--accent);
  background: rgba(182, 243, 107, .1);
  border: 1px solid rgba(182, 243, 107, .18);
  border-radius: 22px;
}
.overlay-icon svg { width: 44px; height: 44px; }
.overlay-kicker { margin-bottom: 9px; color: var(--accent); font: 500 10px 'DM Mono', monospace; letter-spacing: .15em; }
.overlay-content h2 { margin-bottom: 10px; font-size: clamp(24px, 3vw, 34px); line-height: 1.12; letter-spacing: -.055em; }
.overlay-content p:not(.overlay-kicker) { max-width: 300px; margin: 0 auto 22px; color: #b0bcb1; font-size: 13px; line-height: 1.7; }
.primary-button, .secondary-button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 800;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.primary-button { width: 100%; color: var(--accent-ink); background: var(--accent); box-shadow: 0 6px 24px rgba(182, 243, 107, .13); }
.primary-button:hover { background: #c7ff87; transform: translateY(-1px); }
.secondary-button { width: 100%; color: var(--text); background: #252f27; border: 1px solid #344135; }
.secondary-button:hover { background: #2c382e; border-color: #52644f; }
.game-sidebar { display: grid; gap: 14px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.panel-heading h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.04em; }
.field-label { display: block; margin: 0 0 8px; color: #c9d3c9; font-size: 12px; font-weight: 700; }
.field-select {
  width: 100%;
  min-height: 44px;
  margin-bottom: 16px;
  padding: 0 12px;
  color: var(--text);
  background: #111713;
  border: 1px solid #344135;
  border-radius: 10px;
  font-size: 12px;
}
.settings-note { margin: -2px 0 17px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid #29322b; }
.control-description { color: #c0ccc1; font-size: 11px; }
.key-group { display: flex; gap: 4px; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 6px;
  color: #e3ebe2;
  background: #242d26;
  border: 1px solid #3a463c;
  border-radius: 6px;
  box-shadow: 0 2px 0 #101510;
  font: 11px 'DM Mono', monospace;
}
.touch-hint { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.tip-card { display: flex; gap: 12px; padding: 17px; border: 1px solid rgba(182, 243, 107, .16); border-radius: 16px; background: rgba(182, 243, 107, .055); }
.tip-spark { display: grid; place-items: center; flex: 0 0 30px; height: 30px; color: var(--accent); background: rgba(182, 243, 107, .1); border-radius: 10px; }
.tip-card h3 { margin: 1px 0 5px; font-size: 12px; }
.tip-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.game-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; color: #788579; font-size: 10px; }
.mobile-controls { display: none; }
.score-pop { animation: score-pop .25s ease; }
@keyframes pulse { 50% { opacity: .4; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes score-pop { 50% { color: #fff; transform: scale(1.12); } }

@media (max-width: 850px) {
  .snake-app { width: min(680px, calc(100% - 32px)); padding-top: 20px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-sidebar { grid-template-columns: 1fr 1fr; align-items: start; }
  .tip-card { grid-column: 1 / -1; }
  .board-frame { border-radius: 17px; }
}
@media (max-width: 560px) {
  .snake-app { width: calc(100% - 24px); padding-top: 14px; }
  .game-header { gap: 10px; margin-bottom: 19px; }
  .back-link { min-width: 0; width: 30px; font-size: 0; }
  .back-arrow { font-size: 22px; }
  .brand { gap: 9px; }
  .brand-mark { width: 39px; height: 39px; border-radius: 12px; }
  .brand-mark svg { width: 25px; height: 25px; }
  h1 { font-size: 22px; }
  .eyebrow { font-size: 8px; }
  .status-pill { padding: 8px 9px; font-size: 10px; }
  .score-strip { gap: 7px; margin-bottom: 12px; }
  .score-card { min-height: 67px; padding: 10px; border-radius: 12px; }
  .score-label { font-size: 8px; letter-spacing: .08em; }
  .score-card strong { font-size: 20px; }
  .level-card strong { font-size: 14px; }
  .board-frame { border-radius: 14px; }
  .game-overlay { padding: 20px; }
  .overlay-icon { width: 54px; height: 54px; margin-bottom: 16px; border-radius: 18px; }
  .overlay-icon svg { width: 36px; height: 36px; }
  .overlay-content h2 { font-size: 25px; }
  .overlay-content p:not(.overlay-kicker) { font-size: 12px; margin-bottom: 17px; }
  .game-sidebar { grid-template-columns: 1fr; gap: 10px; }
  .panel { padding: 17px; }
  .tip-card { grid-column: auto; }
  .mobile-controls { display: flex; flex-direction: column; align-items: center; gap: 7px; margin: 14px 0 4px; touch-action: none; }
  .horizontal-controls { display: flex; justify-content: center; gap: 7px; }
  .direction-button {
    display: grid; place-items: center; width: 58px; height: 50px;
    color: var(--text); background: #202a22; border: 1px solid #3b4b3c;
    border-radius: 13px; font-size: 23px; font-weight: 700;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .direction-button:active { color: var(--accent-ink); background: var(--accent); }
  .game-footer { flex-direction: column; gap: 5px; margin-top: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
