:root {
  --bg: #120d0a; --panel: rgba(40, 28, 20, .78); --line: rgba(255, 200, 140, .2);
  --text: #f6e9dc; --muted: #bfa58c; --accent: #ffb13b; --accent2: #ff5a36; --ok: #4be08a;
  --title: 'Black Ops One', Impact, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #4a2e1c 0%, #22160f 50%, var(--bg) 100%) fixed;
  color: var(--text); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; overflow: hidden;
}
.hidden { display: none !important; }

.btn {
  font: 600 14px system-ui, sans-serif; color: var(--text); cursor: pointer;
  background: linear-gradient(#6a4a33, #4a3222); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); box-shadow: 0 0 12px rgba(255, 180, 100, .3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 17px; padding: 12px 28px; letter-spacing: .5px; }
.btn.primary { background: linear-gradient(#ffb13b, #e0681a); color: #1a0d00; border-color: #ffcf80; box-shadow: 0 4px 20px rgba(255, 140, 40, .35); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; flex: none; }
.icon-btn:hover { background: rgba(255, 200, 140, .1); }
.icon-btn.off { opacity: .4; text-decoration: line-through; }
.icon-btn.on { border-color: var(--accent); color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 440px; margin: 8px auto 0; }

/* Home */
#home { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.hero { text-align: center; }
.logo {
  font-family: var(--title); font-weight: 400; font-size: clamp(56px, 14vw, 130px); margin: 0; letter-spacing: 6px;
  background: linear-gradient(#fff 10%, #ffd9a0 50%, #e0681a 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 150, 60, .45)); animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px) rotate(-1deg); } }
.tag { color: var(--muted); font-size: 18px; margin: 0 0 32px; letter-spacing: 2px; text-transform: uppercase; }

/* Game */
#game { height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: rgba(20, 12, 8, .75); backdrop-filter: blur(6px); z-index: 5; flex: none; }
.mini-logo { font-family: var(--title); font-size: 24px; color: #ffd9a0; text-decoration: none; letter-spacing: 2px; }
.status { flex: 1; text-align: center; font-weight: 700; font-size: 16px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.wait { color: var(--muted); } .status.win { color: var(--ok); }
.timer { font: 700 17px ui-monospace, Consolas, monospace; color: var(--accent); padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; letter-spacing: 1px; }
.timer.stop { color: var(--ok); }
.dots { display: flex; gap: 4px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .4); }
.dots i.off { opacity: .3; }
.dots i.me { box-shadow: 0 0 0 2px #fff; }

.lobby { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: center; padding: 20px 16px; }
.preview { position: relative; max-width: min(760px, 100%); }
.preview img { display: block; max-width: 100%; max-height: 70vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); border: 1px solid var(--line); }
.preview img[src=""] { display: none; }
.no-img { padding: 40px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); max-width: 420px; text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.lobby-side { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.lobby-side h2 { font-family: var(--title); font-weight: 400; margin: 0; font-size: 22px; letter-spacing: 2px; text-align: center; color: #ffd9a0; }
.share { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.share .row { flex-wrap: nowrap; }
.share input { flex: 1; min-width: 0; background: #1a110b; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px ui-monospace, monospace; }
.players { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.players span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; background: rgba(0, 0, 0, .25); font-size: 13px; }
.players span.off { opacity: .45; }
.players i { width: 10px; height: 10px; border-radius: 50%; }
.size { display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); }
.size select { background: #1a110b; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: inherit; }

.table { flex: 1; position: relative; overflow: hidden; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.ref { position: absolute; left: 12px; bottom: 12px; max-width: min(320px, 40vw); max-height: 35vh; border-radius: 8px; border: 2px solid rgba(255, 220, 180, .5); box-shadow: 0 6px 24px rgba(0, 0, 0, .6); pointer-events: none; opacity: .95; }
.score { position: absolute; right: 12px; top: 12px; background: rgba(20, 12, 8, .78); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; pointer-events: none; min-width: 180px; }
.score h3 { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.score div { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.score i, .rank i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.score span { flex: 1; } .score b { font-variant-numeric: tabular-nums; }
.score small { color: var(--muted); width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.rank { width: 100%; border-collapse: collapse; margin: 14px 0 4px; font-size: 14px; }
.rank th { color: var(--muted); font-weight: 600; font-size: 12px; text-align: right; padding: 3px 6px; }
.rank td { color: var(--text); text-align: right; padding: 4px 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rank th:nth-child(2), .rank td:nth-child(2) { text-align: left; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 18px; }

.modal { position: fixed; inset: 0; background: rgba(10, 5, 0, .6); display: grid; place-items: center; z-index: 20; padding: 16px; animation: fade .4s; }
.modal-box { background: linear-gradient(#4a3222, #2a1b12); border: 1px solid var(--line); border-radius: 18px; padding: 26px 30px; text-align: center; max-width: 460px; width: 100%; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.modal-box h2 { font-family: var(--title); font-weight: 400; font-size: 44px; margin: 0 0 12px; letter-spacing: 3px; }
.modal-box h2.win { color: var(--ok); text-shadow: 0 0 30px rgba(75, 224, 138, .6); }
.modal-box h2.lose { color: var(--accent2); }
#modalBody { color: var(--muted); margin: 0 0 20px; }
#modalBody p { margin: 0 0 10px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; margin: 0 auto 6px; max-width: 380px; }
.info dt { color: var(--muted); } .info dd { margin: 0; color: var(--text); font-weight: 600; }
.info a { color: var(--accent); font-weight: 400; font-size: 13px; }
.place { font-size: 20px; color: var(--text); font-weight: 700; margin-bottom: 14px !important; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.login-wrap { position: fixed; top: 12px; right: 16px; z-index: 10; text-align: right; }
#loginToggle { font-size: 13px; padding: 6px 12px; background: rgba(40, 28, 20, .6); }
.login-pop { position: absolute; right: 0; top: 42px; width: 260px; text-align: left; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.login-pop h3 { margin: 0; font-size: 15px; color: #ffd9a0; font-weight: 600; }
.login-pop p { margin: 0 0 8px; font-size: 14px; }
#createGallery { margin-top: 12px; }
.login { display: flex; flex-direction: column; gap: 8px; }
.login input, .nick input { background: #1a110b; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.err { color: var(--accent2); font-size: 13px; margin: 0; min-height: 1em; }
.nick { display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); }
.nick input { width: 180px; }
.albums { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
#albums { max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 2px; background: rgba(0, 0, 0, .2); border-radius: 8px; padding: 6px 8px; }
#albums label { display: flex; gap: 8px; align-items: center; color: var(--text); cursor: pointer; }
#albums small { color: var(--muted); margin-left: auto; }
#albums:empty { display: none; }
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 25; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #4a3222; border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; transition: transform .35s; z-index: 30; font-weight: 600; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 620px) {
  .top { gap: 6px; padding: 6px 8px; } .mini-logo { font-size: 18px; } .status { font-size: 13px; }
  .dots { display: none; } .timer { font-size: 14px; padding: 3px 6px; } .score { top: auto; bottom: 12px; min-width: 0; } .icon-btn { width: 32px; height: 32px; font-size: 15px; }
}
