@font-face {
  font-family: "IM Fell English Local";
  src: url("../assets/fonts/im-fell-english-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Roboto Condensed Local";
  src: url("../assets/fonts/roboto-condensed-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --panel: #0d1a11;
  --panel-deep: #081109;
  --line: #1b3323;
  --line-soft: #142718;
  --ink: #d9eddd;
  --muted: #7e9986;
  --faint: #3c5a45;
  --jade: #46d98b;
  --jade-deep: #1e7a4f;
  --gold: #d8b36a;
  --ember: #ff7a2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(900px 600px at 50% 14%, rgba(70, 217, 139, 0.12), transparent 62%),
    linear-gradient(180deg, #0b0e13 0%, #060c08 100%);
  color: var(--ink);
  font-family: "Roboto Condensed Local", "Arial Narrow", Arial, sans-serif;
  overflow-x: hidden;
  overscroll-behavior: none;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.46;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px);
}

button {
  font: inherit;
}

.portal-link {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  top: max(14px, env(safe-area-inset-top));
  z-index: 4;
  color: rgba(217, 237, 221, 0.76);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

.portal-link:hover,
.portal-link:focus-visible {
  color: var(--gold);
}

.game-header,
.game-table,
.keys,
.touch-pad,
footer {
  position: relative;
  z-index: 1;
}

.game-header {
  padding: 24px 16px 8px;
  text-align: center;
}

.game-header h1 {
  margin: 0;
  font-family: "IM Fell English Local", Georgia, serif;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 400;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
}

.game-header .rule {
  width: min(340px, 70vw);
  height: 1px;
  margin: 9px auto 6px;
  background: linear-gradient(90deg, transparent, rgba(216, 179, 106, 0.5), var(--gold), rgba(216, 179, 106, 0.5), transparent);
}

.game-header p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
}

.game-table {
  display: grid;
  grid-template-columns: 110px auto 128px;
  gap: 16px;
  align-items: start;
  justify-content: center;
  padding: 12px 12px 8px;
}

.side {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 10px 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), #0a150e);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 10px 30px rgba(0, 0, 0, 0.45);
}

.panel h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.panel canvas {
  display: block;
  margin: 0 auto;
}

.stat {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.stat:last-child {
  margin-bottom: 0;
}

.stat span {
  color: var(--faint);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.stat strong {
  color: var(--ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat:first-child strong,
#score,
#score-mobile {
  color: var(--gold);
}

.mobile-next,
.mobile-score {
  display: none;
}

.board-shell {
  position: relative;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #0c1810, var(--panel-deep));
  box-shadow:
    inset 0 0 0 1px rgba(70, 217, 139, 0.05),
    inset 0 2px 14px rgba(0, 0, 0, 0.6),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

#board {
  display: block;
  border-radius: 4px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 8px;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 22px;
  border-radius: 6px;
  background: rgba(5, 10, 7, 0.86);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay-title {
  color: var(--ink);
  font-family: "IM Fell English Local", Georgia, serif;
  font-size: clamp(25px, 6vw, 34px);
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.overlay-title.gold {
  color: var(--gold);
}

.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.7;
  text-transform: uppercase;
}

.overlay button {
  min-height: 44px;
  margin: 6px auto 0;
  padding: 0 24px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #58e39a, var(--jade));
  color: #071009;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.keys {
  margin: 3px 0 10px;
  padding: 0 12px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 2;
  text-align: center;
}

.keys b {
  color: var(--muted);
}

.touch-pad {
  display: none;
  grid-template-columns: repeat(4, minmax(58px, 76px));
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
  touch-action: none;
}

.touch-pad button {
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(18, 36, 23, 0.7), #0b160e);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  touch-action: none;
}

.touch-pad button:active {
  border-color: var(--jade-deep);
  background: #1b3a26;
}

.touch-pad button[data-action="drop"] {
  color: var(--gold);
}

footer {
  padding: 4px 12px 18px;
  color: rgba(217, 237, 221, 0.45);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(216, 179, 106, 0.8);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .game-header {
    padding-top: 44px;
  }

  .game-header h1 {
    font-size: clamp(27px, 8vw, 36px);
  }

  .game-table {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px 4px;
  }

  .side {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    width: 100%;
    max-width: 430px;
  }

  .side-right {
    display: none;
  }

  .side .panel {
    flex: 1;
    padding: 7px 8px 8px;
  }

  .panel h2 {
    margin-bottom: 4px;
    font-size: 8px;
  }

  .stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
  }

  .stat span {
    font-size: 8px;
  }

  .stat strong {
    font-size: 15px;
  }

  .mobile-next,
  .mobile-score {
    display: block;
  }

  .keys {
    display: none;
  }
}

@media (pointer: coarse) {
  .touch-pad {
    display: grid;
  }

  .keys {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay {
    transition: none;
  }
}
