
@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/PressStart2P.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'VT323';
  src: url('fonts/VT323.woff2') format('woff2');
  font-display: swap;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  font-family: 'VT323', 'Press Start 2P', monospace;
  color: #ffd60a;
}
body {

      background:
        repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,.12) 3px, rgba(0,0,0,.12) 4px),
        radial-gradient(ellipse at 50% 0%, #4a5568 0%, transparent 55%),
        linear-gradient(180deg, #1a1c2c 0%, #2b2d42 50%, #1a1c2c 100%);

}
#app {
  position: relative;
  min-height: 100%;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: clamp(8px, 2.5vw, 18px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vw, 14px);
}

#app::after {
  content: '';
  pointer-events: none;
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.08) 2px, rgba(0,0,0,.08) 3px);
  z-index: 5;
}
header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
h1 {
  margin: 0;
  font-family: 'Press Start 2P', 'VT323', monospace;
  font-size: clamp(1.1rem, 5.5vw, 1.85rem);
  line-height: 1.15;
  text-shadow: 3px 3px 0 #000;
  letter-spacing: 0.02em;
}
.tag {
  width: 100%;
  margin: 0;
  opacity: .85;
  font-size: clamp(.75rem, 2.8vw, .95rem);
}
.scores {
  display: flex; gap: 8px;
}
.scorebox {
  background: #0f111a;
  border: 4px solid #ffd60a;
  border-radius: 4px;
  padding: 6px 12px;
  text-align: center;
  min-width: 72px;
}
.scorebox .label { font-size: .65rem; text-transform: uppercase; opacity: .75; letter-spacing: .06em; }
.scorebox .val { font-size: 1.15rem; font-weight: 700; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700;
  background: #ffd60a; color: #0f111a;
  border-radius: 4px;
  padding: 8px 14px;
  box-shadow: 3px 3px 0 #000;
}
button:disabled { opacity: .45; cursor: default; }
button:active { transform: translateY(1px); }
#board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: min(72vh, 100vw);
  touch-action: none;
  user-select: none;
}
#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(6px, 1.8vw, 10px);
  width: 100%; height: 100%;
  padding: clamp(6px, 1.8vw, 10px);
  background: #0f111a;
  border: 4px solid #ffd60a;
  border-radius: 4px;
}
.cell {
  position: relative;
  border-radius: 0;
  background: #2b2d42;
}
.tile {
  position: absolute; inset: 0;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 140ms ease, background 140ms ease;
  overflow: hidden;
}
.tile.empty { background: transparent !important; box-shadow: none !important; border: none !important; }
.tile.pop { animation: pop 140ms ease; }
@keyframes pop {
  0% { transform: scale(.6); }
  80% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.tile-emoji {
  width: 58%; height: 58%; object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.3));
  pointer-events: none;
}
.tile-main {
  font-weight: 800;
  font-size: clamp(1rem, 6vw, 1.8rem);
  font-family: 'Press Start 2P', 'VT323', monospace;
  line-height: 1;

  image-rendering: pixelated;
}
.tile-badge {
  position: absolute; top: 4px; right: 6px;
  font-size: clamp(.55rem, 2.2vw, .75rem);
  font-weight: 700; opacity: .9;
  font-family: 'VT323', 'Press Start 2P', monospace;
}
#overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  border-radius: 4px;
  z-index: 10;
  backdrop-filter: blur(2px);
}
#overlay[hidden] { display: none !important; }
.overlay-card {
  background: #0f111a;
  border: 4px solid #ffd60a;
  border-radius: 4px;
  padding: 18px 20px;
  text-align: center;
  max-width: 86%;
  color: #ffd60a;
}
.overlay-card h2 { margin: 0 0 6px; font-family: 'Press Start 2P', 'VT323', monospace; }
.overlay-card p { margin: 0 0 12px; }
.overlay-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
footer {
  margin-top: auto;
  text-align: center;
  font-size: .7rem;
  opacity: .55;
}
footer span { opacity: .9; }
@media (min-width: 700px) {
  #app { padding-top: 20px; }
}
