@font-face {
  font-family: 'Tykkiris Display';
  src: url('assets/fonts/press-start-2p-latin-400.woff2') format('woff2'),
       url('assets/fonts/press-start-2p-latin-400.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Tykkiris LCD';
  src: url('assets/fonts/vt323-latin-400.woff2') format('woff2'),
       url('assets/fonts/vt323-latin-400.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-deep: #04061a;
  --bg-panel: #0a1030;
  --frame-gold: #c9a227;
  --frame-gold-dark: #7a611a;
  --lcd-bg: #06102a;
  --lcd-glow: #35d1ff;
  --lcd-glow-dim: #1a4a66;
  --ink: #dce6ff;
  --cell-size: clamp(20px, 6.2vmin, 34px);

  --c-red: #ef3340;
  --c-yellow: #ffd400;
  --c-cyan: #22c9ff;
  --c-magenta: #ff3fae;
  --c-green: #29d17a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #0d1440 0%, var(--bg-deep) 70%);
  color: var(--ink);
  font-family: 'Tykkiris LCD', monospace;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 16, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-box {
  background: linear-gradient(180deg, #101a44, #070b24);
  border: 3px solid var(--frame-gold);
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--frame-gold-dark), 0 0 40px rgba(201, 162, 39, 0.25);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.modal-title {
  font-family: 'Tykkiris Display', monospace;
  font-size: clamp(18px, 5vw, 26px);
  color: var(--c-yellow);
  text-shadow: 0 0 10px rgba(255, 212, 0, 0.6);
  letter-spacing: 2px;
  margin: 0 0 18px;
}

.modal-title.small { font-size: clamp(14px, 4vw, 18px); color: var(--c-cyan); text-shadow: 0 0 10px rgba(34, 201, 255, 0.6); }

.about-list {
  text-align: left;
  font-size: clamp(15px, 3.6vw, 18px);
  line-height: 1.55;
  color: var(--ink);
  padding-left: 1.2em;
  margin: 0 0 22px;
}

.about-list li { margin-bottom: 8px; }

.modal-text { font-size: clamp(15px, 3.6vw, 19px); margin: 6px 0; }

.name-label { display: block; margin: 14px 0 8px; font-size: 16px; }

.name-input {
  width: 100%;
  padding: 10px 12px;
  font-family: 'Tykkiris LCD', monospace;
  font-size: 20px;
  background: var(--lcd-bg);
  border: 2px solid var(--frame-gold-dark);
  border-radius: 6px;
  color: var(--lcd-glow);
  text-align: center;
  outline: none;
}

.name-input:focus { border-color: var(--frame-gold); }

.btn {
  font-family: 'Tykkiris Display', monospace;
  font-size: 13px;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  margin-top: 18px;
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(180deg, #ffe45a, var(--frame-gold));
  color: #2a1d00;
  box-shadow: 0 3px 0 var(--frame-gold-dark);
}

.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--frame-gold-dark); }

.btn-secondary {
  background: linear-gradient(180deg, #3a4a7a, #1c2650);
  color: var(--ink);
  box-shadow: 0 3px 0 #0c1230;
}

.btn-secondary:active { transform: translateY(2px); box-shadow: 0 1px 0 #0c1230; }

.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- App layout ---------- */

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 12px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-wrap { width: 100%; max-width: 440px; margin: 4px auto 10px; }
.logo { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)); }

.game-wrap {
  display: flex;
  flex-direction: row;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.arena-wrap { position: relative; flex: 0 0 auto; }

.board {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  grid-template-rows: repeat(14, var(--cell-size));
  gap: 2px;
  background: #050a1c;
  padding: 8px;
  border: 4px solid var(--frame-gold);
  border-radius: 10px;
  box-shadow:
    inset 0 0 24px rgba(0,0,0,0.85),
    0 0 0 3px var(--frame-gold-dark),
    0 0 30px rgba(201,162,39,0.2);
  background-image:
    radial-gradient(circle at 30% 20%, rgba(60,80,160,0.35), transparent 60%),
    linear-gradient(180deg, #0a1230, #05081a);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 3px;
  background: rgba(255,255,255,0.02);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

.cell.filled {
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,0.55),
    inset 0 -4px 6px rgba(0,0,0,0.45),
    0 0 6px rgba(0,0,0,0.5);
  border-radius: 3px;
}

.cell.falling { filter: brightness(1.15); }

.cell.c-red { background: var(--c-red); }
.cell.c-yellow { background: var(--c-yellow); }
.cell.c-cyan { background: var(--c-cyan); }
.cell.c-magenta { background: var(--c-magenta); }
.cell.c-green { background: var(--c-green); }

/* ---------- Side panel ---------- */

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 190px;
  flex: 0 0 auto;
}

.lcd-panel {
  background: linear-gradient(180deg, #142055, #0a1030);
  border: 3px solid var(--frame-gold);
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--frame-gold-dark), inset 0 0 12px rgba(0,0,0,0.6);
  padding: 8px 10px;
}

.lcd-label {
  font-family: 'Tykkiris Display', monospace;
  font-size: 10px;
  color: var(--c-yellow);
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-align: center;
}

.lcd-digits {
  background: var(--lcd-bg);
  border-radius: 4px;
  color: var(--lcd-glow);
  text-shadow: 0 0 8px var(--lcd-glow), 0 0 2px var(--lcd-glow);
  font-size: 26px;
  letter-spacing: 3px;
  text-align: center;
  padding: 4px 0;
  border: 1px solid #06263a;
}

.top3-panel { }

.results-top10-list {
  max-height: 260px;
  overflow-y: auto;
  font-size: 15px;
  text-align: left;
}

.top10-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--lcd-glow);
}

.top10-list li {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 2px;
  border-bottom: 1px dashed rgba(53, 209, 255, 0.15);
  white-space: nowrap;
  overflow: hidden;
}

.top10-list .t10-rank { color: var(--c-yellow); width: 1.4em; flex: 0 0 auto; }
.top10-list .t10-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.top10-list .t10-score { flex: 0 0 auto; color: var(--c-yellow); font-weight: bold; }
.top10-list .t10-empty { color: var(--lcd-glow-dim); text-align: center; width: 100%; justify-content: center; }

.results-top10-list li {
  flex-wrap: wrap;
  white-space: normal;
}
.results-top10-list .t10-removed {
  flex: 0 0 100%;
  text-align: right;
  font-size: 11px;
  color: var(--lcd-glow-dim);
}

.stats-panel .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--ink);
  padding: 2px 0;
}

.stats-panel .stat-row span:last-child {
  color: var(--c-yellow);
  font-size: 16px;
}

/* ---------- Touch controls ---------- */

.touch-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  background: linear-gradient(180deg, #142055, #0a1030);
  border: 3px solid var(--frame-gold);
  border-radius: 8px;
  padding: 8px;
}

.tc-row { display: flex; gap: 8px; }

.tc-btn {
  font-family: 'Tykkiris Display', monospace;
  font-size: 14px;
  width: 52px;
  height: 44px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg, #3a4a7a, #1c2650);
  color: var(--ink);
  box-shadow: 0 3px 0 #0c1230;
  cursor: pointer;
  touch-action: manipulation;
}

.tc-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0c1230; }

.tc-drop {
  width: 112px;
  background: linear-gradient(180deg, #ffe45a, var(--frame-gold));
  color: #2a1d00;
  box-shadow: 0 3px 0 var(--frame-gold-dark);
  font-size: 12px;
}

.tc-drop:active { box-shadow: 0 1px 0 var(--frame-gold-dark); }

.hint {
  margin-top: 14px;
  font-size: 13px;
  color: var(--lcd-glow-dim);
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  :root { --cell-size: clamp(22px, 10.6vw, 34px); }

  .game-wrap {
    flex-direction: row;
    align-items: flex-start;
  }

  .side-panel {
    width: 118px;
  }

  .lcd-digits { font-size: 16px; letter-spacing: 1px; }
  .lcd-label { font-size: 8px; }
  .top10-list { font-size: 10px; }
  .stats-panel .stat-row { font-size: 9px; flex-direction: column; gap: 0; }
  .stats-panel .stat-row span:last-child { font-size: 12px; }

  .touch-controls { padding: 6px; gap: 4px; }
  .tc-btn { width: 40px; height: 38px; font-size: 12px; }
  .tc-drop { width: 88px; font-size: 10px; }

  .hint { display: none; }
}

@media (max-width: 380px) {
  .side-panel { width: 100px; }
  .tc-btn { width: 34px; height: 34px; }
  .tc-drop { width: 74px; }
}
