/* Atari Multiplayer Arcade - shared styles (lobby + rooms) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --ink: #e4e7ef; --dim: #8f98ad; --acc: #64b5f6; --hot: #ffd166; --red: #ff6b6b;
  --panel: rgba(255,255,255,0.05); --line: rgba(255,255,255,0.12); --bg: #101426;
}
html, body { background: var(--bg); }
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  background-attachment: fixed;
  min-height: 100vh; color: var(--ink);
}
.container { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
a { color: var(--acc); }
button { font: inherit; }

/* ------------------------------------------------------------- header */
header.top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
header.top .home { color: var(--dim); text-decoration: none; font-size: .9rem; }
header.top .home:hover { color: var(--acc); }
header.top h1 { font-size: clamp(1.4rem, 3.4vw, 2.1rem); font-weight: 300; color: #fff; flex: 1; min-width: 200px; }
h1 span, .brand span { font-weight: 700; background: linear-gradient(90deg, #ff6b6b, #ffd166); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.net { font-size: .82rem; color: var(--dim); white-space: nowrap; }
.net.on { color: #8fd694; }
.net.off { color: var(--red); }

/* ------------------------------------------------------------- room */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .stage { grid-template-columns: 1fr; } }

#tv {
  position: relative; margin: 0 auto; aspect-ratio: 4 / 3;
  width: min(100%, calc((100vh - 150px) * 4 / 3)); min-width: 280px;
  background: #000; border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 0 1px #2a3350, 0 18px 60px rgba(0,0,0,.6), 0 0 80px rgba(100,181,246,.12);
}
#tv:fullscreen { width: auto; height: 100%; max-width: 100vw; border-radius: 0; margin: auto; }
#tv:-webkit-full-screen { width: auto; height: 100%; border-radius: 0; }
#screen { display: block; width: 100%; height: 100%; }
#tv.scan::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 50%, rgba(0,0,0,.28) 50%, rgba(0,0,0,.28) 100%);
  background-size: 100% calc(100% / 224);
}
#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, rgba(15,52,96,.65), rgba(0,0,0,.92)); color: #fff; text-align: center; padding: 20px;
}
#overlay[hidden], #invite[hidden], #soundhint[hidden], #resyncing[hidden] { display: none; }
#overlay b { font-size: 1.15rem; font-weight: 600; }
.spin { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--hot); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#invite { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); padding: 14px; }
#invite .box {
  background: #141c36; border: 2px solid var(--hot); border-radius: 14px; padding: 20px 26px; text-align: center;
  box-shadow: 0 0 60px rgba(255,209,102,.35); max-width: 420px; width: 100%; animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#invite h2 { color: var(--hot); font-size: 1.6rem; margin-bottom: 6px; }
#invite p { margin: 6px 0; color: #dfe4f0; }
#invite .tbar { height: 8px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; margin: 12px 0 4px; }
#invite .tbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--hot)); transform-origin: left; }
#invite .tbar i.run { animation: drain linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
#invite button { margin: 10px 4px 0; }
#soundhint {
  position: absolute; right: 10px; bottom: 10px; background: rgba(10,14,30,.8); color: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 12px; font-size: .85rem; cursor: pointer;
}
#resyncing { position: absolute; left: 10px; top: 10px; background: rgba(10,14,30,.8); color: var(--hot); border-radius: 12px; padding: 3px 10px; font-size: .78rem; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px auto 0; }
button.b, .tools button, .row button, #invite button {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font-size: .9rem; cursor: pointer;
}
.tools button:hover, .row button:hover, #invite button:hover { border-color: var(--acc); color: #fff; }
.tools button:disabled { opacity: .5; cursor: default; }
.row button.go, #invite button.go { background: linear-gradient(135deg, #ff6b6b, #c0392b); border-color: transparent; color: #fff; font-weight: 600; }
.row button.go:hover, #invite button.go:hover { filter: brightness(1.1); }
button.link { background: none; border: 0; color: var(--acc); cursor: pointer; font-size: .85rem; text-decoration: underline; }

.side { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card h2 { font-size: .95rem; color: #fff; font-weight: 600; margin-bottom: 8px; letter-spacing: .02em; }
#you { border-color: rgba(255,209,102,.35); }
#you .big { font-size: 1.12rem; color: #fff; margin-bottom: 4px; }
#you .pl { font-weight: 700; }
#you .hint { color: #c5cbd8; font-size: .9rem; line-height: 1.45; margin: 4px 0; }
#you .warn { color: var(--hot); font-size: .92rem; line-height: 1.45; margin: 4px 0; font-weight: 600; }
#you .msg { color: var(--dim); }
#you .row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
#you .name { color: var(--dim); font-size: .82rem; }
#you .name b { color: var(--ink); font-weight: 600; }

#seats { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.seat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,.18); border-left: 4px solid var(--c); }
.seat .chip { grid-row: span 2; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 700;
  color: #111; background: var(--c); font-size: .9rem; }
.seat .who { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .who em { font-style: normal; color: var(--hot); font-weight: 400; }
.seat .tag { font-size: .78rem; color: var(--dim); }
.seat.free { border-left-style: dashed; opacity: .75; }
.seat.free .chip { background: transparent; color: var(--c); border: 2px dashed var(--c); }
.seat.free .who { color: var(--dim); font-weight: 400; }
.seat.free.cpu { opacity: .9; }
.seat.free.cpu .chip { border-style: dotted; }
.seat.pick { cursor: pointer; transition: background .15s, opacity .15s, transform .15s; }
.seat.pick:hover, .seat.pick:focus-visible { opacity: 1; background: rgba(255,255,255,.08); transform: translateX(2px); outline: none; }
.seat.pick:hover .chip, .seat.pick:focus-visible .chip { background: var(--c); color: #111; border-style: solid; }
.seat.pick:hover .who, .seat.pick:focus-visible .who { color: #fff; }
.seat.me { background: rgba(255,209,102,.1); }
.seat.dim .who { color: var(--dim); }

#line { list-style: decimal inside; color: #c5cbd8; font-size: .9rem; max-height: 220px; overflow: auto; }
#line li { padding: 2px 0; }
#line li.me { color: var(--hot); font-weight: 600; }
#line li.dim { list-style: none; color: var(--dim); }
#watchers { color: var(--dim); font-size: .82rem; margin-top: 6px; }
#best { list-style: decimal inside; color: #c5cbd8; font-size: .9rem; }
#best li { padding: 2px 0; display: list-item; }
#best li .bn { display: inline-block; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
#best li .bs { float: right; color: #fff; font-variant-numeric: tabular-nums; }
#best li.me, #best li.me .bs { color: var(--hot); font-weight: 600; }
#best li.dim { list-style: none; color: var(--dim); }
.card .note { color: var(--dim); font-size: .75rem; margin-top: 6px; }
.game .top { color: var(--hot); font-size: .88rem; min-height: 1.2em; }
.privnote { margin-top: 10px; color: var(--hot) !important; font-weight: 600; }
.game.locked { pointer-events: none; opacity: .55; }

/* bug report */
.tools button.bugbtn { border-color: rgba(255,107,107,.45); color: #ffb3b3; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(5,8,20,.72); padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: #141c36; border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; width: min(520px, 100%);
  box-shadow: 0 20px 70px rgba(0,0,0,.6); animation: pop .2s ease-out; }
.modal h2 { color: #fff; font-size: 1.25rem; margin-bottom: 6px; }
.modal p { color: #c5cbd8; line-height: 1.45; font-size: .93rem; margin: 6px 0; }
.modal textarea { width: 100%; margin: 8px 0 2px; background: #0c1226; color: #fff; border: 1px solid #39446a; border-radius: 8px;
  padding: 10px; font: inherit; font-size: .95rem; resize: vertical; min-height: 110px; }
.modal textarea:focus { outline: 2px solid var(--acc); border-color: transparent; }
.modal .fine { color: var(--dim); font-size: .78rem; }
.modal .msg { min-height: 1.3em; font-weight: 600; }
.modal .msg.ok { color: #8fd694; }
.modal .msg.err { color: var(--hot); }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.modal .row button { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; font-size: .95rem; cursor: pointer; }
.modal .row button.go { background: linear-gradient(135deg, #ff6b6b, #c0392b); border-color: transparent; color: #fff; font-weight: 600; }
.modal .row button:disabled { opacity: .5; cursor: default; }

/* touch controls (phones / tablets) */
#touch { display: none; justify-content: space-between; align-items: center; gap: clamp(8px, 4vw, 16px); margin: 12px auto 0; max-width: 520px; user-select: none; -webkit-user-select: none; }
body.touch #touch { display: flex; }
/* the D-pad: a cross; the arm being pushed lights up (left/right only for Joust) */
#pad { --s: clamp(120px, 40vw, 168px); width: var(--s); height: var(--s); flex: none; position: relative; touch-action: none; border-radius: 50%;
  background: radial-gradient(circle, #1d2642 0%, #131a2f 70%); border: 2px solid #2c3858; }
#pad .arm, #pad .hub { position: absolute; display: block; background: linear-gradient(135deg, #3a4a72, #252f4c); border: 2px solid #46557e;
  box-shadow: 0 3px 8px rgba(0,0,0,.45); transition: background .05s; }
#pad .u, #pad .d { left: 50%; width: calc(var(--s) * .32); margin-left: calc(var(--s) * -.16); height: calc(var(--s) * .36); }
#pad .u { top: calc(var(--s) * .05); border-radius: 12px 12px 4px 4px; border-bottom: 0; }
#pad .d { bottom: calc(var(--s) * .05); border-radius: 4px 4px 12px 12px; border-top: 0; }
#pad .l, #pad .r { top: 50%; height: calc(var(--s) * .32); margin-top: calc(var(--s) * -.16); width: calc(var(--s) * .36); }
#pad .l { left: calc(var(--s) * .05); border-radius: 12px 4px 4px 12px; border-right: 0; }
#pad .r { right: calc(var(--s) * .05); border-radius: 4px 12px 12px 4px; border-left: 0; }
#pad .hub { left: 50%; top: 50%; width: calc(var(--s) * .32); height: calc(var(--s) * .32); margin: calc(var(--s) * -.16) 0 0 calc(var(--s) * -.16); border-color: transparent; box-shadow: none; }
#pad .arm::after { position: absolute; inset: 0; display: grid; place-items: center; color: #8f98ad; font-size: calc(var(--s) * .107); }
#pad .u::after { content: "\25B2"; } #pad .d::after { content: "\25BC"; } #pad .l::after { content: "\25C0"; } #pad .r::after { content: "\25B6"; }
#pad .arm.on { background: linear-gradient(135deg, #ffd166, #e0993a); border-color: #ffe29a; }
#pad .arm.on::after { color: #3a2a00; }
body.dpad-lr #pad .u, body.dpad-lr #pad .d { opacity: .18; }
.tbtns { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.abrow { display: flex; gap: clamp(8px, 3vw, 12px); align-items: center; }
.nesonly { display: none; }
body.nes .nesonly { display: flex; }
body.nes button.nesonly { display: block; }
.tbtns .small { gap: 6px; }
.tbtns .small button { border: 1px solid #4a5677; background: #232c46; color: #ffd166; border-radius: 6px; padding: 6px 10px; font-size: .75rem; font-weight: 700; touch-action: none; }
.tbtn { width: clamp(58px, 19vw, 84px); height: clamp(58px, 19vw, 84px); border-radius: 50%; border: 0; color: #fff; font-weight: 700; font-size: 1.05rem;
  background: linear-gradient(135deg, #6f8cff, #3b4fb0); box-shadow: 0 6px 18px rgba(59,79,176,.5); touch-action: none; }
#tfire { width: clamp(72px, 24vw, 104px); height: clamp(72px, 24vw, 104px); border-radius: 50%; border: 0; color: #fff; font-weight: 700; font-size: 1.05rem; background: linear-gradient(135deg, #ff6b6b, #b02a2a); box-shadow: 0 6px 18px rgba(176,42,42,.5); touch-action: none; }
.down { filter: brightness(1.45); transform: scale(.96); }

/* ------------------------------------------------------------- info + footer */
.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 26px; }
.info .card p, .info .card li { color: #c5cbd8; line-height: 1.55; font-size: .93rem; }
.info .card ul { list-style: none; }
.info .card li { margin: 3px 0; }
kbd { display: inline-block; min-width: 1.6em; text-align: center; padding: 1px 6px; border-radius: 5px; background: #0f1528; border: 1px solid #39446a; border-bottom-width: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: #fff; }
footer { margin-top: 26px; text-align: center; color: var(--dim); font-size: .8rem; line-height: 1.6; }
footer a { color: #9fb4d8; }

/* ------------------------------------------------------------- lobby */
.hero { text-align: center; margin: 18px 0 26px; }
.hero .home { color: var(--dim); text-decoration: none; font-size: .9rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 300; color: #fff; text-shadow: 0 0 30px rgba(100,200,255,.45); margin: 8px 0 6px; }
.hero p { color: var(--dim); font-size: 1.05rem; }
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; }
.game {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden; transition: transform .15s ease, border-color .15s, box-shadow .15s;
}
.game:hover { transform: translateY(-3px); border-color: var(--hot); box-shadow: 0 14px 40px rgba(0,0,0,.45); }
.game img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: fill; background: #000; display: block; }
.game .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game h2 { color: #fff; font-size: 1.35rem; font-weight: 600; }
.game h2 small { color: var(--hot); font-weight: 400; font-size: .9rem; margin-left: 6px; }
.game p { color: #c5cbd8; line-height: 1.5; font-size: .93rem; }
.game .status { color: #8fd694; font-weight: 600; font-size: .92rem; }
.game .status.full { color: var(--hot); }
.game .ver { color: var(--dim); font-size: .8rem; margin-top: -4px; }
.game .cta { margin-top: auto; align-self: flex-start; background: linear-gradient(135deg, #ff6b6b, #c0392b); color: #fff; font-weight: 600; padding: 8px 16px; border-radius: 8px; }
/* a lobby card: the whole card plays (the Play link's ::after covers it); "See How It Was Made" sits above */
.game { position: relative; }
.game .links { margin-top: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.game .links .cta { margin-top: 0; text-decoration: none; }
.game .cta.play::after { content: ""; position: absolute; inset: 0; border-radius: 16px; }
.game .cta.how { position: relative; z-index: 1; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.game .cta.how:hover, .game .cta.how:focus-visible { border-color: var(--hot); color: #fff; background: rgba(255,255,255,.1); }

@media (max-width: 600px) { .container { padding: 12px 10px 30px; } #tv { border-radius: 8px; } }

/* "<name> joined!" toasts: bounce in at the top right, hop, slide away */
#toasts { position: fixed; top: 14px; right: 14px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end;
  gap: 8px; pointer-events: none; max-width: calc(100vw - 28px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 12px; color: #fff;
  background: #141c36; border: 1px solid var(--line); border-left: 4px solid var(--c);
  box-shadow: 0 10px 30px rgba(0,0,0,.55), 0 0 22px rgba(255,209,102,.18);
  animation: toast-in .8s cubic-bezier(.25,1.5,.5,1) both, toast-hop .7s ease-out .85s 2, toast-out .45s ease-in 4.4s forwards; }
.toast .chip { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; flex: none;
  background: var(--c); color: #101426; animation: toast-spin .6s ease-out .15s both; }
.toast .words { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.toast b { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast small { color: var(--dim); font-size: .78rem; }
@keyframes toast-in {
  0% { transform: translateY(-140%) scale(.6); opacity: 0; }
  50% { transform: translateY(12%) scale(1.06); opacity: 1; }
  70% { transform: translateY(-10%) scale(.98); }
  85% { transform: translateY(3%); }
  100% { transform: none; opacity: 1; }
}
@keyframes toast-hop { 0%, 100% { transform: none; } 30% { transform: translateY(-10px); } 55% { transform: none; } 72% { transform: translateY(-3px); } }
@keyframes toast-spin { from { transform: rotate(-200deg) scale(.3); } to { transform: none; } }
@keyframes toast-out { to { transform: translateX(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: toast-out .45s ease-in 4.4s forwards; }
  .toast .chip { animation: none; }
}
