@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  font-family: 'DM Sans', sans-serif;
  color: #f5f0ff;
  background: #100b26;
  font-synthesis: none;
  color-scheme: dark;
  --purple: #b7a0ff;
  --cyan: #55f4ef;
  --lime: #d2ff5a;
  --pink: #ff6bd8;
  --muted: #b6acce;
  --line: #ffffff20;
  --panel: #19132f;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--cyan); outline-offset: 4px;
}
.hidden { display: none !important; }

/* Atmospheric motion stays behind the interface, away from the puzzle letters. */
.arcade-background { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.arcade-background::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #c9baff06 3px 4px);
}
.ambient-glow { position: absolute; width: 900px; height: 900px; border-radius: 50%; opacity: .6; }
.glow-pink {
  left: -420px; top: -370px;
  background: radial-gradient(circle, #bd258c45, #8b28cb20 37%, transparent 68%);
  animation: glow-drift 28s ease-in-out infinite alternate;
}
.glow-blue {
  right: -380px; top: 5%;
  background: radial-gradient(circle, #3877d849, #5329ae22 40%, transparent 68%);
  animation: glow-drift 34s ease-in-out -14s infinite alternate-reverse;
}
.arcade-grid {
  position: absolute; width: 180%; left: -40%; height: 70%; bottom: -32%;
  background-image: linear-gradient(#a064ff50 1px, transparent 1px), linear-gradient(90deg, #a064ff50 1px, transparent 1px);
  background-size: 72px 72px;
  transform: perspective(650px) rotateX(58deg); transform-origin: center top;
  mask-image: linear-gradient(transparent, #000 35%, #000);
  opacity: .43; animation: grid-flow 24s linear infinite;
}
.pixel-stars i { position: absolute; width: 7px; height: 7px; background: var(--cyan); opacity: .42; animation: star-drift 22s ease-in-out infinite alternate; }
.pixel-stars i:nth-child(1) { left: 7%; top: 22%; box-shadow: 0 0 16px #55f4ef55; }
.pixel-stars i:nth-child(2) { left: 47%; top: 14%; width: 5px; height: 5px; background: var(--pink); animation-delay: -10s; }
.pixel-stars i:nth-child(3) { right: 8%; top: 39%; background: var(--lime); animation-delay: -5s; }
.pixel-stars i:nth-child(4) { left: 18%; bottom: 19%; width: 4px; height: 4px; background: var(--pink); animation-delay: -16s; }
.pixel-stars i:nth-child(5) { right: 37%; bottom: 27%; width: 5px; height: 5px; animation-delay: -8s; }
.pixel-stars i:nth-child(6) { right: 4%; bottom: 8%; background: var(--purple); animation-delay: -20s; }
@keyframes glow-drift { to { transform: translate(70px, 55px) scale(1.12); } }
@keyframes grid-flow { to { background-position: 0 72px, 0 72px; } }
@keyframes star-drift { to { transform: translateY(-24px) rotate(90deg); } }

.header, main, footer { position: relative; z-index: 1; }
.header { max-width: 1240px; margin: auto; padding: 30px 40px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 4px; text-decoration: none; color: #fff; font: 700 25px 'Space Grotesk', sans-serif; letter-spacing: -1px; }
.brand-mark { background: var(--lime); color: #151123; width: 37px; height: 37px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 23px; position: relative; margin-right: 8px; box-shadow: 3px 3px 0 var(--pink), 0 0 25px #d2ff5a12; transform: rotate(-5deg); }
.brand-mark span { font-size: 14px; position: absolute; right: 3px; top: 1px; }
.brand-purple { color: var(--cyan); }
.beta { font: 600 9px ui-monospace, monospace; letter-spacing: 1px; border: 1px solid #ff6bd84a; padding: 5px 7px; border-radius: 4px; margin-left: 10px; color: var(--pink); }
.connection { font-size: 12px; color: var(--muted); }
.connection[data-status] { font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--cyan); background: var(--panel); border: 1px solid var(--cyan); border-radius: 10px; padding: 10px 16px; box-shadow: 0 4px 16px #00000030; }
.connection[data-status='connecting'], .connection[data-status='reconnecting'] { color: var(--lime); border-color: var(--lime); }
main { max-width: 1160px; padding: 0 40px; margin: auto; min-height: calc(100vh - 175px); }
.home { display: grid; grid-template-columns: 1.25fr 1fr; gap: 90px; padding: 75px 0 60px; align-items: center; }
.eyebrow, .small-label { font: 600 10px ui-monospace, 'Courier New', monospace; letter-spacing: 2px; }
.eyebrow { color: var(--pink); }
.eyebrow::before { content: '✦ '; }
h1 { font: 700 clamp(40px, 5vw, 67px)/1.04 'Space Grotesk', sans-serif; letter-spacing: -3px; margin: 22px 0; }
h1 span { color: var(--lime); }
h1 .hero-fast { color: var(--cyan); }
.hero-copy h1 { text-shadow: 0 4px 0 #03001140; }
.hero-description { font-size: 17px; line-height: 1.8; color: var(--muted); }
.hero-tags { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.hero-tags span { font: 600 11px ui-monospace, monospace; border: 1px solid #b7a0ff3f; padding: 8px 12px; border-radius: 6px; background: #201733; color: #d3c5ec; }
.hero-tags span:nth-child(2) { color: var(--pink); border-color: #ff6bd84a; }
.hero-tags span:nth-child(3) { color: var(--cyan); border-color: #55f4ef3b; }
.demo-grid { display: grid; grid-template-columns: repeat(5, 43px); gap: 7px; transform: rotate(-6deg); margin: 43px 0 5px 12px; max-width: 245px; }
.demo-grid span { display: flex; align-items: center; justify-content: center; height: 43px; border: 1px solid #51406c; border-radius: 7px; background: #211a37; font: 600 19px 'Space Grotesk', sans-serif; color: #b5a7ce; box-shadow: 0 3px 0 #090619; }
.demo-grid span:nth-child(-n+5) { background: var(--pink); color: #260c28; border-color: #ff9ae5; box-shadow: 0 3px 0 #a33594, 0 0 22px #ff6bd818; }
.entry-card, .players-card, .scores-card { background: linear-gradient(145deg, #221a3a, #171329 75%); border: 1px solid #64517e66; border-radius: 18px; padding: 32px; box-shadow: 0 18px 55px #02000d55, inset 0 1px 0 #ffffff0a; }
.entry-card { position: relative; border-color: #ff6bd865; box-shadow: 6px 6px 0 #ff6bd826, 0 20px 70px #08000f55; }
.entry-card::before { content: ''; position: absolute; top: -1px; left: 30px; width: 80px; height: 3px; background: var(--pink); border-radius: 0 0 4px 4px; box-shadow: 0 0 18px #ff6bd855; }
.entry-card .small-label { color: var(--pink); }
h2 { font: 700 23px 'Space Grotesk', sans-serif; letter-spacing: -.8px; margin: 16px 0 10px; }
.entry-card > p { font-size: 13px; color: var(--muted); line-height: 1.7; margin: 0 0 26px; }
label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 9px; color: #e5daf5; }
input, select { width: 100%; border: 1px solid #574568; border-radius: 8px; padding: 14px 15px; background: #100c20; color: #fff; min-width: 0; transition: border-color .18s, box-shadow .18s; }
input:hover, select:hover { border-color: #9175a9; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px #55f4ef0c; }
input::placeholder { color: #9687ac; }
.button { border: 0; border-radius: 8px; font-weight: 700; font-size: 14px; padding: 15px 19px; display: flex; justify-content: space-between; gap: 25px; align-items: center; transition: transform .15s, background .15s, box-shadow .15s; }
.button:active { transform: translateY(3px); }
.primary { background: var(--lime); color: #192208; box-shadow: 0 4px 0 #748f28, 0 0 25px #d2ff5a0c; }
.primary:hover { background: #e2ff90; box-shadow: 0 4px 0 #748f28, 0 0 30px #d2ff5a26; transform: translateY(-1px); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #748f28; }
.dark { background: var(--cyan); color: #082e32; box-shadow: 0 4px 0 #248789; }
.dark:hover { background: #98fffa; }
.entry-card .primary { width: 100%; margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 12px; color: #a695bd; font-size: 11px; margin: 27px 0; }
.divider::before, .divider::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.join-row { display: flex; gap: 9px; }
#room-code { text-transform: uppercase; letter-spacing: 3px; font-family: ui-monospace, monospace; }
.entry-card .entry-note { font-size: 10px; margin: 22px 0 0; text-align: center; }
.room-bar { display: flex; align-items: center; justify-content: space-between; padding: 23px 0; border-bottom: 1px solid var(--line); }
.room-bar .small-label { font-size: 9px; color: var(--muted); letter-spacing: 1.5px; display: block; }
.code-button { border: 0; background: none; padding: 5px 0 0; font: 700 23px 'Space Grotesk', sans-serif; letter-spacing: 3px; color: var(--cyan); }
.copy-icon { color: var(--pink); font-size: 20px; }
.text-button { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 12px 0; }
.text-button:hover { color: var(--pink); }
#leave { color: #fff; background: var(--panel); border: 1px solid var(--pink); border-radius: 9px; padding: 12px 18px; min-height: 44px; font-size: 14px; font-weight: 700; box-shadow: 0 4px 14px #00000030; transition: background .15s, color .15s; }
#leave:hover { color: #241633; background: var(--pink); }
.lobby { display: grid; grid-template-columns: 1.25fr 1fr; gap: 80px; padding: 50px 0; align-items: start; }
.lobby h1 { font-size: 54px; }
.lobby-copy > p { font-size: 14px; color: var(--muted); line-height: 1.8; }
.rules { margin: 25px 0; }
.rules > div { display: flex; gap: 14px; align-items: center; margin: 14px 0; font-size: 13px; }
.rules b { color: var(--cyan); font: 600 11px ui-monospace, monospace; background: #55f4ef10; border: 1px solid #55f4ef27; padding: 7px; border-radius: 5px; }
.setup { max-width: 350px; border-top: 1px solid var(--line); padding-top: 20px; }
.setup .button { width: 100%; margin-top: 15px; }
.difficulty-label { margin-top: 18px; }
.difficulty-summary { font: 10px/1.8 ui-monospace, monospace; color: var(--cyan); margin: 10px 0 0; }
.muted { font-size: 12px; color: var(--muted); line-height: 1.7; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.card-heading h2 { margin: 0; font-size: 21px; }
.pill { font: 600 10px ui-monospace, monospace; background: #55f4ef12; color: var(--cyan); border: 1px solid #55f4ef33; padding: 6px 10px; border-radius: 6px; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--player-color); color: white; font: 700 17px 'Space Grotesk', sans-serif; border-radius: 9px; border: 1px solid #ffffff25; flex-shrink: 0; }
.player-detail { flex: 1; min-width: 0; }
.player-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-status { font-size: 10px; color: var(--muted); margin-top: 4px; }
.player-score { font: 700 24px 'Space Grotesk', sans-serif; color: var(--lime); }
.player-rank { font: 11px ui-monospace, monospace; color: #ab96c4; width: 12px; }
.you-badge { font-size: 9px; font-weight: 500; color: var(--cyan); margin-left: 5px; }
.game { display: grid; grid-template-columns: minmax(0, 570px) minmax(220px, 1fr); gap: 60px; padding: 28px 0 45px; align-items: start; }
.round-bar { display: flex; align-items: center; justify-content: space-between; color: var(--muted); margin-bottom: 14px; }
.round-bar .small-label { font-size: 10px; letter-spacing: 1px; }
.round-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.difficulty-badge { font: 600 9px ui-monospace, monospace; letter-spacing: 1px; border: 1px solid #b7a0ff55; background: #b7a0ff14; color: var(--purple); padding: 5px 8px; border-radius: 5px; }
.difficulty-badge[data-level='easy'] { color: var(--cyan); border-color: #55f4ef55; background: #55f4ef10; }
.difficulty-badge[data-level='hard'] { color: var(--pink); border-color: #ff6bd855; background: #ff6bd810; }
.timer { font: 600 16px 'Space Grotesk', sans-serif; color: var(--cyan); background: #55f4ef10; border: 1px solid #55f4ef3a; padding: 6px 12px; border-radius: 7px; min-width: 59px; text-align: center; }
.timer.urgent { background: #ff6bd81c; color: #ff9be7; border-color: #ff6bd860; }
.target-card { background: linear-gradient(125deg, #302045, #241835); border: 1px solid #ff6bd858; border-radius: 13px; text-align: center; padding: 18px 12px 12px; min-height: 130px; margin-bottom: 19px; box-shadow: inset 0 1px 0 #ff6bd815, 0 7px 25px #09021630; }
.target-card .small-label { color: var(--pink); font-size: 9px; }
.target-card h2 { font-size: 35px; letter-spacing: 5px; color: var(--lime); margin: 8px 0; text-shadow: 0 0 22px #d2ff5a12; }
.target-card p { font-size: 11px; color: #cebcdf; min-height: 16px; margin: 0; }
.board { display: grid; grid-template-columns: repeat(var(--board-size, 9), minmax(0, 1fr)); gap: 5px; touch-action: none; user-select: none; -webkit-user-select: none; padding: 10px; border: 1px solid #b6a4dc; border-radius: 15px; background: #dcd3ee; box-shadow: 0 12px 35px #00000025; }
.board[data-size='11'] { gap: 4px; }
.board[data-size='11'] .cell { font-size: clamp(14px, 1.8vw, 21px); }
.cell { aspect-ratio: 1; border: 1px solid #cec3e1; background: #fcfaff; color: #241633; border-radius: 7px; font: 700 clamp(13px, 2vw, 23px) 'Space Grotesk', sans-serif; box-shadow: 0 3px 0 #bdb0d4; padding: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
.cell:disabled { opacity: 1; }
.cell:hover:not(:disabled) { border-color: #8260ad; }
.cell.selected { background: var(--cyan); color: #073637; border-color: #a6fffa; box-shadow: 0 3px 0 #1e8c8e, 0 0 14px #55f4ef25; }
.cell.found { background: var(--lime); color: #24330b; border-color: #e5ff9d; box-shadow: 0 3px 0 #7b962c; }
.cell.missed { background: #ffb7e9; color: #4e163f; border-color: #e775c2; box-shadow: 0 3px 0 #c46eac; }
.board.inactive .cell { cursor: default; }
.board-footer { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; color: var(--muted); margin-top: 16px; }
.board-footer span:last-child { color: var(--cyan); }
.scores-card { margin-top: 0; padding: 26px; border-top: 2px solid #55f4ef70; }
.live-label { font: 600 9px ui-monospace, monospace; color: var(--cyan); letter-spacing: 1px; display: flex; align-items: center; gap: 5px; }
.live-label i { width: 6px; height: 6px; background: var(--cyan); border-radius: 50%; box-shadow: 0 0 9px #55f4ef70; }
.score-note { font-size: 11px; color: var(--muted); line-height: 1.8; padding-top: 24px; }
.results { text-align: center; padding: 45px 0 55px; max-width: 480px; margin: auto; }
.trophy { margin: 22px auto; background: #ff6bd818; border: 1px solid #ff6bd866; width: 85px; height: 85px; display: flex; align-items: center; justify-content: center; border-radius: 18px; font-size: 46px; color: var(--lime); box-shadow: 5px 5px 0 #ff6bd81f; transform: rotate(-8deg); }
.results h1 { font-size: 43px; letter-spacing: -2px; overflow-wrap: anywhere; color: var(--lime); }
.results > p { color: var(--muted); font-size: 14px; line-height: 1.8; }
.final-players { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 8px 24px; margin: 25px 0; text-align: left; }
.final-players .player-row:last-child { border: 0; }
.results .button { width: 100%; }
footer { max-width: 1160px; margin: auto; padding: 20px 40px; border-top: 1px solid var(--line); font: 9px ui-monospace, monospace; letter-spacing: 1.5px; color: #a998be; display: flex; justify-content: space-between; gap: 20px; }
footer > span { letter-spacing: 0; font: 10px 'DM Sans', sans-serif; }
footer .footer-motto { font: 9px ui-monospace, monospace; letter-spacing: 1.5px; align-self: center; }
.footer-tools { display: flex; align-items: center; gap: 20px; }
.footer-credit { font: 10px 'DM Sans', sans-serif; letter-spacing: 0; }
.motion-toggle { border: 1px solid #55f4ef35; border-radius: 6px; background: #55f4ef0a; color: var(--cyan); padding: 7px 10px; font: 10px ui-monospace, monospace; white-space: nowrap; }
.motion-toggle[aria-pressed='false'] { color: var(--muted); border-color: #b7a0ff35; background: #b7a0ff0a; }
:root[data-motion='off'] .arcade-background * { animation: none !important; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #2d2141; border: 1px solid #b7a0ff65; color: white; box-shadow: 0 8px 24px #00000050; border-radius: 10px; padding: 14px 22px; font-size: 13px; z-index: 10; max-width: 90vw; text-align: center; }
.toast.error { background: #512143; border-color: #ff6bd880; }

@media (min-width: 1300px) { .home { padding-top: 90px; } }
@media (max-width: 850px) {
  .header { padding: 22px 24px; }
  main { padding: 0 24px; }
  .home { gap: 30px; padding: 50px 0; grid-template-columns: 1fr 1fr; }
  h1 { font-size: 43px; letter-spacing: -2px; }
  .hero-description { font-size: 14px; }
  .entry-card { padding: 24px; }
  .entry-card h2 { font-size: 20px; }
  .lobby { gap: 30px; }
  .lobby h1 { font-size: 43px; }
  .game { gap: 25px; grid-template-columns: minmax(0, 1fr) 220px; }
  .scores-card { padding: 19px; }
  .scores-card .avatar { width: 29px; height: 29px; font-size: 14px; border-radius: 7px; }
  .scores-card .player-row { gap: 8px; }
  .scores-card .player-name { font-size: 11px; }
  .cell { border-radius: 5px; }
  .brand .beta { display: none; }
}
@media (max-width: 620px) {
  .header { padding: 20px; }
  .brand { font-size: 22px; }
  .connection { max-width: 125px; text-align: right; font-size: 10px; }
  .header { flex-wrap: wrap; gap: 14px; }
  .connection[data-status] { max-width: none; width: 100%; text-align: left; font-size: 13px; padding: 10px 13px; }
  main { padding: 0 20px; }
  .home { grid-template-columns: 1fr; gap: 30px; padding: 35px 0; }
  .hero-copy h1 { font-size: clamp(39px, 8.4vw, 47px); }
  .hero-description { font-size: 15px; }
  .hero-tags { margin-top: 20px; gap: 8px; }
  .hero-tags span { padding: 8px 10px; font-size: 10px; }
  .demo-grid { display: none; }
  .entry-card { padding: 26px; }
  .lobby { grid-template-columns: 1fr; padding-top: 30px; gap: 22px; }
  .lobby h1 { font-size: 43px; }
  .setup { max-width: none; }
  .players-card { padding: 24px; }
  .game { grid-template-columns: 1fr; padding-top: 20px; gap: 28px; }
  .board { gap: 4px; padding: 7px; border-radius: 12px; }
  .cell { font-size: clamp(14px, 4.3vw, 19px); border-radius: 5px; }
  .board[data-size='11'] { gap: 3px; }
  .board[data-size='11'] .cell { font-size: clamp(13px, 3.7vw, 17px); border-radius: 4px; }
  .target-card { min-height: 118px; padding-top: 15px; }
  .target-card h2 { font-size: 30px; letter-spacing: 4px; }
  .scores-card { padding: 22px; }
  .scores-card .avatar { width: 34px; height: 34px; }
  .scores-card .player-name { font-size: 13px; }
  .score-note { display: none; }
  .scores-card .player-row { padding: 10px 0; }
  .results h1 { font-size: 37px; }
  .results { padding-top: 30px; }
  footer { padding: 20px; letter-spacing: 1px; flex-wrap: wrap; gap: 12px; }
  footer .footer-motto { text-align: left; }
  .footer-tools { width: 100%; justify-content: space-between; gap: 12px; }
  .footer-credit { max-width: 210px; line-height: 1.7; }
  .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
  .ambient-glow { width: 650px; height: 650px; opacity: .5; }
  .glow-pink { left: -340px; top: -230px; }
  .glow-blue { right: -390px; top: 25%; }
  .arcade-grid { opacity: .27; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  :root:not([data-motion='on']) *, :root:not([data-motion='on']) *::before, :root:not([data-motion='on']) *::after { animation: none !important; }
}
