* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  margin: 0; background: #05060d; overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #e8ecf6;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
}
canvas#game {
  display: block;
  touch-action: none;
  border: 1px solid rgba(124,108,255,.25);
  border-radius: 10px;
  box-shadow: 0 0 80px rgba(124,108,255,.18);
  background: #06070f;
}
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,5,12,.68);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  padding: 14px;
}
.overlay.hidden { display: none; }
.panel {
  width: min(94vw, 560px); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(16,18,34,.96), rgba(10,12,24,.96));
  border: 1px solid rgba(124,108,255,.35);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55), inset 0 0 60px rgba(124,108,255,.05);
  text-align: center;
}
.logo { font-size: clamp(30px, 7vw, 44px); font-weight: 900; letter-spacing: .16em; line-height: 1.05; }
.logo span {
  background: linear-gradient(90deg, #7c6cff, #41d8c3);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: block;
}
.sub { color: #9aa4c0; font-size: 14px; margin: 12px 0 20px; }
.sub b { color: #41d8c3; }
.nameRow { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.nameRow label { font-size: 12px; letter-spacing: .25em; color: #7c6cff; font-weight: 700; }
#nameInput {
  width: 220px; background: rgba(255,255,255,.05); color: #e8ecf6;
  border: 1px solid rgba(124,108,255,.4); border-radius: 10px;
  padding: 10px 14px; font-size: 16px; text-align: center;
  letter-spacing: .12em; text-transform: uppercase; outline: none;
}
#nameInput:focus { border-color: #41d8c3; box-shadow: 0 0 18px rgba(65,216,195,.25); }
.btn {
  cursor: pointer; border: none; border-radius: 12px;
  font: 700 15px/1 inherit; letter-spacing: .14em; color: #0b0e1a;
  background: linear-gradient(135deg, #7c6cff, #41d8c3);
  padding: 14px 30px; text-transform: uppercase;
  box-shadow: 0 8px 30px rgba(124,108,255,.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(124,108,255,.5); }
.btn:active { transform: translateY(0); }
.btn.big { width: 100%; font-size: 17px; padding: 16px 30px; }
.btn.ghost { background: transparent; color: #9aa4c0; border: 1px solid rgba(255,255,255,.18); box-shadow: none; }
.btn.ghost:hover { color: #e8ecf6; border-color: rgba(124,108,255,.5); }
.controls {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 18px 0 6px; font-size: 12px; color: #9aa4c0;
}
.controls span b { display: block; color: #41d8c3; font-size: 11px; letter-spacing: .2em; margin-bottom: 2px; }
.boardWrap { margin-top: 6px; }
.boardWrap h3 { font-size: 12px; letter-spacing: .3em; color: #7c6cff; margin: 14px 0 8px; }
.board table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.board th { color: #66709a; font-size: 10px; letter-spacing: .2em; text-align: left; padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.board td { padding: 5px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.04); }
.board tr.me td { color: #41d8c3; background: rgba(65,216,195,.07); }
.board tr td:nth-child(3) { color: #ffd45c; font-weight: 700; }
.board .empty { color: #66709a; font-size: 13px; padding: 14px 0; }
.board .more { color: #66709a; font-size: 11px; padding: 8px 0 0; }
.foot { margin-top: 18px; color: #66709a; font-size: 11px; }
.foot a { color: #9aa4c0; text-decoration: none; border-bottom: 1px dotted #66709a; }
.foot a:hover { color: #41d8c3; }
.overTitle { font-size: 30px; letter-spacing: .2em; color: #ff5082; text-shadow: 0 0 30px rgba(255,80,130,.5); margin-bottom: 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0; }
.srow { display: flex; justify-content: space-between; padding: 8px 12px; background: rgba(255,255,255,.04); border-radius: 8px; font-size: 13px; }
.srow span { color: #9aa4c0; letter-spacing: .08em; }
.srow b { font-variant-numeric: tabular-nums; }
.rank { font-size: 15px; color: #9aa4c0; margin: 6px 0 14px; min-height: 20px; }
.rank b { color: #41d8c3; }
.btns { display: flex; gap: 10px; margin-bottom: 4px; }
.btns .btn.big { flex: 1; }
.panel.small { width: min(90vw, 380px); }
.panel.small h2 { letter-spacing: .3em; margin-bottom: 8px; }
.panel.small p { color: #9aa4c0; font-size: 13px; margin-bottom: 16px; }
#bombBtn {
  display: none; position: fixed; right: 18px; bottom: 18px; z-index: 20;
  width: 74px; height: 74px; border-radius: 50%;
  background: rgba(124,108,255,.2); border: 2px solid rgba(124,108,255,.7);
  color: #cabfff; font: 800 13px/1 inherit; letter-spacing: .18em;
  -webkit-tap-highlight-color: transparent;
}
#bombBtn:active { background: rgba(124,108,255,.5); }
@media (hover: none) and (pointer: coarse) { #bombBtn { display: block; } }
#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%) translateY(30px);
  background: rgba(10,12,24,.95); border: 1px solid rgba(124,108,255,.5);
  color: #e8ecf6; font-size: 13px; padding: 8px 18px; border-radius: 999px;
  opacity: 0; transition: all .25s ease; pointer-events: none; z-index: 30;
  max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 640px) {
  .controls { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: 1fr; }
  .btns { flex-direction: column; }
}
