/* ===== NES '89 Tetris — retro styling ===== */

:root {
  --bg: #000;
  --board-bg: #00005a;
  --grid: #000088;
  --white: #f8f8f8;
  --gray: #a8a8a8;
  --yellow: #f8d878;
  --orange: #f8a800;
  --red: #f85830;
  --green: #00e800;
  --blue: #00a8f8;
  --purple: #b800f8;
  --cyan: #00e8d8;
  --panel-border: #f85830;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  user-select: none;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* ===== Cabinet layout ===== */

.cabinet {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.panel {
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-box {
  border: 5px solid var(--panel-border);
  background: #000;
  padding: 8px;
  text-align: center;
}

.panel-label {
  color: var(--red);
  font-size: 14px;
  letter-spacing: 2px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.panel-value {
  color: var(--white);
  font-size: 26px;
  letter-spacing: 3px;
}

.panel-value.tiny {
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 6px;
}

.controls {
  text-align: left;
}
.ctl {
  color: var(--yellow);
  font-size: 12px;
  margin: 3px 0;
  letter-spacing: 1px;
}

#mute-btn {
  width: 100%;
  background: #1a1a3a;
  color: var(--white);
  border: 3px solid #444488;
  font: inherit;
  font-size: 14px;
  letter-spacing: 3px;
  padding: 6px 0;
  cursor: pointer;
  touch-action: manipulation;
}
#mute-btn:active { background: #3a3a6a; }

/* ===== Board ===== */

.board-wrap {
  position: relative;
  border: 6px solid #fff;
  box-shadow: 0 0 0 6px #000, 0 0 30px rgba(0, 168, 248, .35);
}

#board {
  display: block;
  image-rendering: pixelated;
  background: var(--board-bg);
}

/* ===== Overlays (start / pause / game over) ===== */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 40, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 5;
}

.overlay.hidden { display: none; }

.title-art span {
  display: inline-block;
  color: var(--cyan);
  font-size: 44px;
  letter-spacing: 10px;
  font-weight: bold;
  text-shadow: 4px 4px 0 var(--purple), 8px 8px 0 #202040;
}
.title-art span:hover { animation: title-cycle 1s steps(1) infinite; }
@keyframes title-cycle {
  0%   { color: var(--cyan); }
  33%  { color: var(--yellow); }
  66%  { color: var(--green); }
}
.title-sub {
  color: var(--yellow);
  font-size: 14px;
  letter-spacing: 6px;
  margin-top: 4px;
  text-align: center;
}

#overlay-msg {
  color: var(--yellow);
  font-size: 16px;
  letter-spacing: 3px;
  text-align: center;
}

/* ===== Blink animation ===== */
@keyframes blink { 50% { visibility: hidden; } }
.blink { animation: blink 1s steps(1) infinite; }

/* ===== Touch controls (hidden on desktop) ===== */

.touch-controls {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(420px, 95vw);
}

.touch-controls button {
  padding: 16px 0;
  font-size: 20px;
  background: #1a1a3a;
  color: var(--white);
  border: 4px solid #444488;
  touch-action: manipulation;
}
.touch-controls button:active { background: #3a3a6a; }

@media (hover: none), (pointer: coarse) {
  .touch-controls { display: grid; }
}

@media (max-width: 640px) {
  .cabinet { flex-wrap: wrap; justify-content: center; }
  .panel { flex-direction: row; width: auto; flex-wrap: wrap; }
  .panel-box { padding: 5px; }
  .panel-value { font-size: 18px; }
  .controls { display: none; }
  #board { width: 180px; height: 360px; }
}
