:root {
  --bg: #0a0e1a;
  --panel: #111827;
  --panel-edge: #1e2a44;
  --tile: #16213e;
  --tile-hi: #22335e;
  --tile-open: #0c1226;
  --cyan: #00e5ff;
  --magenta: #ff2ec4;
  --lime: #a3ff3c;
  --gold: #ffd23c;
  --red: #ff4d5e;
  --text: #d7e3ff;
  --dim: #6b7aa3;
}

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

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(0,229,255,.08), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(255,46,196,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 14px 22px; border-bottom: 1px solid var(--panel-edge);
  background: rgba(10,14,26,.8); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.logo {
  font-size: 1.5rem; letter-spacing: .18em; font-weight: 800;
  color: var(--cyan); text-shadow: 0 0 14px rgba(0,229,255,.6);
}
.logo span { color: var(--magenta); text-shadow: 0 0 14px rgba(255,46,196,.6); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mute-btn {
  background: transparent; border: 1px solid var(--panel-edge);
  border-radius: 999px; width: 38px; height: 38px; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.mute-btn:hover { border-color: var(--cyan); }
.tab {
  background: transparent; border: 1px solid var(--panel-edge); color: var(--dim);
  padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: .95rem;
  transition: all .15s;
}
.tab.active {
  color: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,229,255,.35), inset 0 0 8px rgba(0,229,255,.1);
}

/* ---------- layout ---------- */
.view { max-width: 1100px; margin: 26px auto; padding: 0 16px; }
.hidden { display: none !important; }

.panel {
  background: linear-gradient(180deg, var(--panel), #0d1424);
  border: 1px solid var(--panel-edge); border-radius: 16px;
  padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.45);
}

.difficulty { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; flex-wrap: wrap; }
.diff {
  background: var(--tile); color: var(--dim); border: 1px solid var(--panel-edge);
  padding: 9px 20px; border-radius: 10px; cursor: pointer; font-size: 1rem;
  transition: all .15s;
}
.diff.active { color: var(--lime); border-color: var(--lime); box-shadow: 0 0 12px rgba(163,255,60,.3); }

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.led {
  font-family: "Courier New", monospace; font-weight: 700; font-size: 1.6rem;
  color: var(--red); background: #05070d; border: 1px solid #2a1520;
  border-radius: 8px; padding: 4px 14px; min-width: 92px; text-align: center;
  text-shadow: 0 0 10px rgba(255,77,94,.8); letter-spacing: .12em;
}
.face {
  background: var(--tile); border: 1px solid var(--panel-edge); color: var(--gold);
  font-size: 1.3rem; width: 54px; height: 54px; border-radius: 50%; cursor: pointer;
  transition: all .15s; text-shadow: 0 0 10px rgba(255,210,60,.6);
}
.face:hover { transform: scale(1.08); border-color: var(--gold); }

/* ---------- grid ---------- */
.grid-wrap { overflow-x: auto; padding-bottom: 6px; }
.grid {
  display: grid; gap: 3px; width: max-content; margin: 0 auto;
  padding: 10px; background: #070b16; border-radius: 12px;
  border: 1px solid var(--panel-edge);
}
.cell {
  width: 34px; height: 34px; border-radius: 6px; border: 0;
  background: linear-gradient(145deg, var(--tile-hi), var(--tile));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 3px rgba(0,0,0,.4);
  cursor: pointer; font-weight: 800; font-size: 1.05rem;
  font-family: "Courier New", monospace;
  display: flex; align-items: center; justify-content: center;
  color: transparent; user-select: none; -webkit-user-select: none;
  transition: background .1s, box-shadow .1s;
}
.cell:hover:not(.open) {
  background: linear-gradient(145deg, #2b4176, var(--tile-hi));
  box-shadow: inset 0 0 0 1px rgba(0,229,255,.5), 0 0 10px rgba(0,229,255,.25);
}
.cell.open {
  background: var(--tile-open);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
  cursor: default;
  animation: pop .15s ease-out;
}
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }

.cell.n1 { color: var(--cyan);    text-shadow: 0 0 8px rgba(0,229,255,.7); }
.cell.n2 { color: var(--lime);    text-shadow: 0 0 8px rgba(163,255,60,.7); }
.cell.n3 { color: var(--magenta); text-shadow: 0 0 8px rgba(255,46,196,.7); }
.cell.n4 { color: var(--gold);    text-shadow: 0 0 8px rgba(255,210,60,.7); }
.cell.n5 { color: #ff8a3c; text-shadow: 0 0 8px rgba(255,138,60,.7); }
.cell.n6 { color: #3cffd2; text-shadow: 0 0 8px rgba(60,255,210,.7); }
.cell.n7 { color: #b73cff; text-shadow: 0 0 8px rgba(183,60,255,.7); }
.cell.n8 { color: #ffffff; text-shadow: 0 0 8px rgba(255,255,255,.7); }

.cell.flag { color: var(--magenta); }
.cell.flag::before {
  content: "⚑"; color: var(--magenta); text-shadow: 0 0 10px rgba(255,46,196,.9);
}
.cell.mine { color: var(--red); }
.cell.mine::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--red) 40%, #7a0f1c 90%);
  box-shadow: 0 0 12px var(--red), 0 0 24px rgba(255,77,94,.5);
}
.cell.boom { background: #3a0d16 !important; }
.cell.mine.p0::before { background: radial-gradient(circle at 35% 35%, #fff, var(--cyan) 40%, #045a66 90%); box-shadow: 0 0 12px var(--cyan); }
.cell.mine.p1::before { background: radial-gradient(circle at 35% 35%, #fff, var(--magenta) 40%, #66044c 90%); box-shadow: 0 0 12px var(--magenta); }

.hint { text-align: center; color: var(--dim); margin-top: 14px; font-size: .88rem; }

/* ---------- modes 3D ---------- */
.canvas-wrap {
  height: 62vh; min-height: 340px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--panel-edge); background: #070b16;
  touch-action: none;
}
.canvas-wrap canvas { display: block; }
.status-led {
  font-family: "Courier New", monospace; font-weight: 700; font-size: 1.1rem;
  color: var(--cyan); background: #05070d; border: 1px solid var(--panel-edge);
  border-radius: 8px; padding: 8px 14px; min-width: 92px; text-align: center;
  text-shadow: 0 0 10px rgba(0,229,255,.7); letter-spacing: .12em;
}

/* ---------- multi ---------- */
.lobby { max-width: 460px; margin: 0 auto; text-align: center; }
.lobby h2 { margin-bottom: 10px; letter-spacing: .05em; }
.live-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 10px var(--lime); margin: 0 4px;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
.rules { color: var(--dim); margin-bottom: 18px; line-height: 1.5; }
.rules b { color: var(--text); }

.lobby input, .join-row input {
  background: #070b16; border: 1px solid var(--panel-edge); color: var(--text);
  padding: 11px 14px; border-radius: 10px; font-size: 1rem; width: 100%;
  outline: none; text-align: center;
}
.lobby input:focus { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,229,255,.25); }
#multi-name { margin-bottom: 14px; }
#multi-code { text-transform: uppercase; letter-spacing: .3em; font-family: "Courier New", monospace; }

.lobby-actions { display: flex; flex-direction: column; gap: 12px; }
.join-row { display: flex; gap: 10px; }

.btn {
  background: var(--tile); border: 1px solid var(--panel-edge); color: var(--text);
  padding: 11px 20px; border-radius: 10px; cursor: pointer; font-size: 1rem;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,229,255,.25); }
.btn.primary {
  background: linear-gradient(90deg, rgba(0,229,255,.15), rgba(255,46,196,.15));
  border-color: var(--cyan); color: var(--cyan); font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--dim); }
.error { color: var(--red); margin-top: 12px; min-height: 1.2em; }

.room-line { text-align: center; color: var(--dim); margin-bottom: 12px; }
.room-line b {
  color: var(--gold); font-family: "Courier New", monospace; font-size: 1.2rem;
  letter-spacing: .3em; text-shadow: 0 0 10px rgba(255,210,60,.5);
}

.scoreboard {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.score {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--panel-edge); min-width: 150px;
  justify-content: space-between;
}
.score .pts { font-family: "Courier New", monospace; font-size: 1.4rem; font-weight: 800; }
.score.p0 { border-color: rgba(0,229,255,.5); }
.score.p0 .pts { color: var(--cyan); text-shadow: 0 0 8px rgba(0,229,255,.6); }
.score.p1 { border-color: rgba(255,46,196,.5); }
.score.p1 .pts { color: var(--magenta); text-shadow: 0 0 8px rgba(255,46,196,.6); }
.score.me { box-shadow: 0 0 14px rgba(255,255,255,.12); }
.score.off { opacity: .4; }
.vs { color: var(--dim); font-size: .9rem; text-align: center; min-width: 110px; }

.multi-actions { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }

@media (max-width: 640px) {
  .cell { width: 28px; height: 28px; font-size: .9rem; }
  .logo { font-size: 1.1rem; }
}
