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

body {
  background: #0d1117;
  color: #e0d8c8;
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}

.wrap { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: min(94vw, calc(82vh * 4 / 5)); }

/* Header */
.bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #1a2a3a;
  border-bottom: 2px solid #ff6b2b;
}
.bar h1 { font-size: 16px; font-weight: bold; color: #ff6b2b; letter-spacing: 2px; text-transform: uppercase; }
.scores { display: flex; align-items: center; gap: 8px; }
.score { font-size: 12px; color: #a0b8c8; }
.score strong { color: #fff; }

.icon-btn {
  background: none; border: 1px solid #334; color: #a0b8c8;
  border-radius: 3px; cursor: pointer; padding: 2px 6px; font-size: 14px;
  text-decoration: none; display: inline-block;
}
.icon-btn:hover { border-color: #ff6b2b; color: #ff6b2b; }

/* Info bar */
.info-bar {
  width: 100%; background: #111d2a; padding: 4px 10px;
  font-size: 11px; color: #7090a0;
  display: flex; flex-wrap: wrap; gap: 0;
}
.info-bar strong { color: #e0d8c8; }

/* Board */
.board {
  position: relative;
  width: 100%;
  background: #080c12;
  line-height: 0;
}
canvas#game {
  width: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Fullscreen */
.wrap:fullscreen,
.wrap:-webkit-full-screen {
  max-width: 100vw;
  width: 100vw;
  min-height: 100vh;
  justify-content: center;
}
.wrap:fullscreen .board,
.wrap:-webkit-full-screen .board {
  flex: 1 1 auto;
}

/* Overlays */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(8, 12, 18, 0.88);
  gap: 12px;
  z-index: 10;
  line-height: 1.3; /* reset .board's line-height:0 so overlay text doesn't collapse/overlap */
}
.overlay.hidden { display: none; }
.ov-title { font-size: 22px; font-weight: bold; color: #ff6b2b; letter-spacing: 3px; text-transform: uppercase; text-align: center; }
.ov-sub { font-size: 13px; color: #a0c0d0; text-align: center; }

/* Character select */
.chars { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.char-card {
  background: #1a2a3a; border: 2px solid #334455;
  border-radius: 4px; padding: 10px 14px;
  cursor: pointer; text-align: center; transition: border-color .15s;
  min-width: 100px;
}
.char-card:hover, .char-card.active { border-color: #ff6b2b; }
.char-card canvas { display: block; margin: 0 auto 6px; image-rendering: pixelated; }
.char-name { display: block; font-size: 13px; font-weight: bold; color: #e0d8c8; }
.char-blurb { display: block; font-size: 10px; color: #607080; margin-top: 2px; }

.play-btn {
  background: #ff6b2b; color: #fff; border: none;
  padding: 10px 32px; font-size: 15px; font-family: inherit;
  font-weight: bold; letter-spacing: 1px; cursor: pointer;
  border-radius: 3px;
}
.play-btn:hover { background: #ff8c55; }

/* Mobile controls — sits below the canvas in normal document flow */
.mobile-controls {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #0d1117;
}
.mobile-controls.show { display: flex; }

.dpad { position: relative; width: 132px; height: 132px; }
.dpad-btn {
  position: absolute; background: rgba(255,107,43,0.35);
  border: 1px solid rgba(255,107,43,0.6); color: #ff6b2b;
  font-size: 18px; cursor: pointer; border-radius: 6px;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.dpad-up    { top: 0;   left: 50%; transform: translateX(-50%); }
.dpad-down  { bottom: 0; left: 50%; transform: translateX(-50%); }
.dpad-left  { top: 50%; left: 0;  transform: translateY(-50%); }
.dpad-right { top: 50%; right: 0; transform: translateY(-50%); }

.action-btns { display: flex; gap: 12px; }
.action-btn {
  background: rgba(255,107,43,0.35); border: 1px solid rgba(255,107,43,0.6);
  color: #ff6b2b; font-size: 13px; font-family: inherit; font-weight: bold;
  cursor: pointer; border-radius: 6px; width: 64px; height: 64px;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.action-btn:active { background: rgba(255,107,43,0.65); }

/* Hint / footer */
.hint { font-size: 11px; color: #405060; padding: 5px 10px; text-align: center; }
.foot { font-size: 10px; color: #2a3a4a; padding: 4px; }
