:root {
  --bg: #142342;
  --panel: #0f1a33;
  --line: #35548f;
  --accent: #51d8ff;
  --text: #f2f6ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #25447f 0%, #101b34 48%, #091224 100%);
}
.app {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px;
  display: grid;
  gap: 12px;
}
.hud {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #122042, #0b1530);
  border-radius: 14px;
  padding: 10px 14px;
}
.hud h1 { margin: 0; color: var(--accent); }
.subhead { margin: 4px 0 8px; font-size: 0.9rem; opacity: 0.85; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px 10px;
  font-weight: 700;
}
.stats strong { color: #ffe88c; }
.game-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}
canvas {
  width: min(100%, 480px);
  height: auto;
  border-radius: 14px;
  border: 2px solid #4668af;
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.42);
  background: #232a39;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(2, 9, 25, 0.72);
}
.overlay.hidden { display: none; }
.card {
  width: min(92%, 440px);
  background: #101d3d;
  border: 1px solid #3f61a5;
  border-radius: 14px;
  padding: 16px;
}
.card h2 { margin: 0 0 8px; }
.card p { margin: 0 0 12px; }
.card ul { margin: 0 0 14px 18px; padding: 0; }
.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
button {
  border-radius: 10px;
  border: 1px solid #4a6fba;
  background: #1b2f63;
  color: white;
  font-weight: 700;
  padding: 10px 12px;
}
button.mode.active {
  background: linear-gradient(180deg, #20c7f0, #0a8bad);
  border-color: #85f0ff;
}
#startBtn {
  width: 100%;
  font-size: 1rem;
  background: linear-gradient(180deg, #1fd2ff, #03809f);
  border-color: #83f2ff;
}
.tips-panel {
  position: absolute;
  top: 18px;
  right: min(0px, calc(50% - 240px));
  transform: translateX(106%);
  transition: transform 220ms ease;
  width: 220px;
  background: rgba(13, 25, 52, 0.94);
  border: 1px solid #486daf;
  border-radius: 12px;
  padding: 10px;
  pointer-events: none;
}
.tips-panel.open { transform: translateX(0); }
.tips-panel h3 { margin: 0 0 8px; color: #8feaff; }
.tips-panel ul { margin: 0; padding-left: 16px; font-size: 0.86rem; }
.hint-toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90%, 420px);
  padding: 8px 12px;
  border: 1px solid #84b0ff;
  border-radius: 999px;
  background: rgba(6, 16, 36, 0.88);
  font-weight: 700;
  text-align: center;
}
.hidden { display: none; }
.controls {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.controls button { min-height: 46px; }
@media (max-width: 820px) {
  .tips-panel { display: none; }
}
