:root {
  --bg: #02050b;
  --panel: #07101e;
  --panel-2: #0a1628;
  --line: rgba(64, 171, 255, 0.32);
  --blue: #125cff;
  --cyan: #18c8ff;
  --white: #f7fbff;
  --muted: #9ba8bf;
  --danger: #ff3864;
  --gold: #f6d36b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(18, 92, 255, 0.22), transparent 30rem),
    linear-gradient(145deg, #00030a, var(--bg) 54%, #020814);
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid rgba(24, 200, 255, 0.55);
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: white;
  min-height: 42px;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(18, 92, 255, 0.28);
}

button:active {
  transform: translateY(1px);
}

.shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.game-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(8, 18, 34, 0.96), rgba(1, 5, 13, 0.96));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55), 0 0 60px rgba(18, 92, 255, 0.12);
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(2, 5, 11, 0.72);
  border-bottom: 1px solid rgba(64, 171, 255, 0.18);
}

.controls {
  border-top: 1px solid rgba(64, 171, 255, 0.18);
  border-bottom: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 48px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(24, 200, 255, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, #0a36e8, #16cbff);
  font-size: 1.55rem;
  font-weight: 950;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.18), 0 0 28px rgba(18, 92, 255, 0.32);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 2vw, 1.8rem);
  line-height: 1;
  font-weight: 900;
  text-transform: lowercase;
  letter-spacing: 0.12em;
}

h1 span {
  color: var(--cyan);
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(68px, 1fr));
  gap: 8px;
}

.stats div {
  min-width: 68px;
  padding: 8px 10px;
  border: 1px solid rgba(64, 171, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.stats span,
.stats small {
  display: block;
}

.stats span {
  font-size: 1.05rem;
  font-weight: 900;
}

.stats small {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.stage-wrap {
  position: relative;
  width: 100%;
  background:
    linear-gradient(rgba(24, 200, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 200, 255, 0.05) 1px, transparent 1px),
    #02050b;
  background-size: 32px 32px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 178px);
  aspect-ratio: 13 / 11;
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 3, 10, 0.62);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid rgba(24, 200, 255, 0.48);
  border-radius: 8px;
  background: rgba(7, 16, 30, 0.92);
  text-align: center;
  box-shadow: 0 0 48px rgba(18, 92, 255, 0.28);
}

.overlay-card strong,
.overlay-card span {
  display: block;
}

.overlay-card strong {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.overlay-card span {
  color: var(--muted);
  margin-bottom: 16px;
}

.overlay-card button {
  width: 100%;
}

.room-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  text-align: left;
}

.room-field span,
.room-chip {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.room-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(24, 200, 255, 0.45);
  border-radius: 8px;
  background: rgba(2, 5, 11, 0.82);
  color: var(--white);
  padding: 0 12px;
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
  outline: none;
}

.room-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(24, 200, 255, 0.15);
}

.room-chip {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(64, 171, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.room-chip strong {
  color: var(--cyan);
}

.room-list-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(64, 171, 255, 0.18);
}

.room-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.room-list-head button {
  width: auto;
  min-height: 30px;
  padding: 0 10px;
  border-color: rgba(64, 171, 255, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: var(--cyan);
  box-shadow: none;
  font-size: 0.72rem;
}

.room-list {
  display: grid;
  gap: 8px;
  max-height: 154px;
  overflow-y: auto;
}

.room-row {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-color: rgba(64, 171, 255, 0.26);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
  text-align: left;
}

.room-row strong,
.room-row span {
  display: block;
}

.room-row strong {
  color: var(--white);
  font-size: 0.92rem;
}

.room-row span,
.room-empty {
  color: var(--muted);
  font-size: 0.78rem;
}

.room-empty {
  padding: 12px;
  border: 1px solid rgba(64, 171, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

kbd {
  min-width: 54px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
}

.touch-pad button {
  width: 56px;
  height: 56px;
  min-height: 56px;
  font-size: 1.35rem;
}

.touch-pad [data-dir="up"] {
  grid-column: 2;
}

.touch-pad [data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-pad [data-dir="bomb"] {
  grid-column: 2;
  grid-row: 2;
  background: linear-gradient(135deg, #111827, #1d2b45);
  color: var(--cyan);
}

.touch-pad [data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.touch-pad [data-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .touch-pad {
    justify-self: center;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  canvas {
    max-height: none;
  }
}
