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

:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #f3f7fa;
  background: #0b111b;
  line-height: 1.55;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 18% 28%, #203f40 0%, transparent 45%),
              radial-gradient(ellipse at 90% 72%, #16294d 0%, transparent 50%);
}

.game-page { width: min(100% - 2rem, 66rem); margin-inline: auto; padding-bottom: 2rem; }
.masthead { padding: 1.1rem 0; border-bottom: 1px solid #ffffff26; }
.back { color: inherit; font-family: Georgia, serif; font-size: 1.15rem; letter-spacing: .05em; text-decoration: none; }
.back span { margin-left: .6rem; color: #b9ccc9; font: 600 .875rem system-ui, sans-serif; letter-spacing: normal; }
.back:hover { text-decoration: underline; text-underline-offset: .25em; }
.game-layout { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: clamp(2rem, 5vw, 5rem); align-items: center; padding-top: clamp(2rem, 5vw, 4.5rem); }
h1 { margin: 0; font-size: clamp(2.75rem, 6vw, 5.25rem); line-height: 1.06; letter-spacing: -.07em; }
.rules { color: #c4d5d6; margin: 1.15rem 0; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.legend li { padding: .3rem .6rem; border: 1px solid currentColor; border-radius: .45rem; font-size: .875rem; }
.legend li span { display: inline-block; width: 1em; font-weight: 800; }
.blue { color: #9ceaff; }
.orange { color: #ffbd91; }
.keyboard { color: #b9ccc9; font-size: .875rem; }
kbd { border: 1px solid #778e92; border-radius: .2rem; padding: .05rem .3rem; }

.console {
  min-width: 0;
  padding: clamp(.7rem, 2vw, 1.25rem);
  border: 1px solid #405465;
  border-radius: 1.15rem;
  background: #101b2b;
  box-shadow: 0 1.5rem 4rem #03081066;
}

.scoreboard { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; margin: 0; }
.scoreboard div { padding: .45rem .25rem; border-radius: .55rem; background: #1c2b40; text-align: center; }
.scoreboard dt, .scoreboard small { color: #c1cde0; font-size: .875rem; }
.scoreboard dd { margin: 0; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.scoreboard .timer { background: #16384a; }
.timer dd { color: #a9efff; }
.scoreboard small { margin-left: .18rem; }
.level-progress { display: grid; gap: .3rem; margin: .75rem 0; color: #c1cde0; font-size: .875rem; }
.level-progress progress { width: 100%; height: .5rem; accent-color: #75dfda; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(.25rem, 1vw, .55rem); }
.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 3rem;
  aspect-ratio: 1.58;
  padding: 0;
  background: radial-gradient(ellipse at 50% 105%, #233f42, transparent 85%), #182735;
  color: #c4d5dc;
  border: 1px solid #425768;
  border-radius: .6rem;
  cursor: pointer;
  touch-action: manipulation;
  font: inherit;
}
.cell:disabled { cursor: default; }
.cell span { position: absolute; top: .24rem; left: .48rem; font-size: .82rem; }
.cell.hit { background: radial-gradient(ellipse, #216c92, #13344d); border-color: #8be9ff; color: #e7fbff; }
.cell.trap { background: radial-gradient(ellipse, #85482b, #412b24); border-color: #ffad79; color: #ffeadf; }
.cell.hit::after, .cell.trap::after { font-size: clamp(1.75rem, 6vw, 3.1rem); font-weight: 800; line-height: 1; text-shadow: 0 0 .8rem currentColor; }
.cell.hit::after { content: '✦'; }
.cell.trap::after { content: '×'; }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem .75rem; margin-top: .8rem; }
.controls p { margin: 0; color: #d0dbea; font-size: .875rem; }
.controls button { min-height: 2.75rem; padding: .5rem 1rem; border: 0; border-radius: .5rem; background: #8be7e0; color: #10262c; font: 800 1rem system-ui, sans-serif; cursor: pointer; }
.controls button:hover { background: #b2fff8; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

@media (max-width: 46rem) {
  .game-page { max-width: 34rem; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding-top: 1.25rem; }
  h1 { font-size: clamp(2rem, 8vw, 3.4rem); }
  h1 br { display: none; }
  .rules { margin: .5rem 0 .65rem; }
  .keyboard { margin-bottom: 0; }
}
