:root {
  --bg: #0b1020;
  --card: #141b31;
  --line: #26304f;
  --text: #e8ecf8;
  --muted: #8f9ab8;
  --accent: #5ee0c0;
  --power: #ffb347;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.menu {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1 {
  margin: 8px 0 6px;
  text-align: center;
  font-size: 44px;
  letter-spacing: 12px;
  color: var(--accent);
}

h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > button { flex: 1 1 0; }

button {
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  min-height: 44px;
  cursor: pointer;
  width: 100%;
}
.row > button { width: auto; }
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.keys { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
@media (pointer: coarse) { .keys { display: none; } }
.msg { margin: 0; padding: 10px 12px; border-radius: 10px; background: #3a1d2a; color: #ffd0dc; }

.wait { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.wait p { margin: 0; }
.wait code {
  display: block;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--bg);
  word-break: break-all;
  user-select: all;
}

.game { position: fixed; inset: 0; background: var(--bg); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
}
button.icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(20, 27, 49, 0.8);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 15px;
}
button.icon.off { opacity: 0.45; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 16, 32, 0.7);
  padding: 16px;
}
.ov-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  width: min(360px, 100%);
  text-align: center;
}
.ov-box p:first-child { margin: 0; font-size: 22px; font-weight: 700; }
.ov-box .row { margin-top: 14px; }
