/* Guess Who — English Room Games */
:root {
  --bg: #1d2452;
  --bg-2: #252d63;
  --ink: #fff8e7;
  --muted: #b9c0ea;
  --muted-2: #8790c4;
  --line: rgba(255, 255, 255, .14);
  --gold: #ffc93c;
  --gold-dark: #c99a1c;
  --red: #e2453c;
  --green: #3bb273;
  --display: 'Fredoka', 'Nunito', sans-serif;
  --body: 'Nunito', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body); color: var(--ink); background-color: var(--bg);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%);
  background-size: 64px 64px; background-position: 0 0, 32px 32px;
  min-height: 100dvh;
}
button, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: rgba(20, 26, 64, .8); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font: 700 26px var(--display); white-space: nowrap; }
.brand .site { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); text-decoration: none; white-space: nowrap; }
.brand .site:hover { color: var(--gold); }
.spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; text-decoration: none; }
.iconbtn:hover { color: var(--ink); border-color: var(--gold); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="false"] .wave { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 760px) 340px; gap: 20px; justify-content: center; align-items: start; padding: 14px 14px 26px; }
.board-title { margin: 0 0 10px; text-align: center; font: 600 1.1rem var(--display); color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding: 14px; border-radius: 20px; background: linear-gradient(160deg, #e2453c, #b7302a); box-shadow: inset 0 3px 0 rgba(255,255,255,.2), 0 16px 34px rgba(0,0,0,.4); }
.person {
  position: relative; border: 0; padding: 0; border-radius: 12px; overflow: hidden; cursor: pointer;
  background: #fff; color: #1d2452; aspect-ratio: 100 / 128; perspective: 600px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .12s;
}
.person:hover { transform: translateY(-2px); }
.person .face, .person .back { position: absolute; inset: 0; backface-visibility: hidden; transition: transform .45s; display: flex; flex-direction: column; }
.person .face svg { width: 100%; flex: 1; display: block; }
.person .face span { font: 700 clamp(.78rem, 1.4vw, 1rem) var(--display); padding: 2px 0 4px; background: #fff; }
.person .back {
  transform: rotateY(180deg); align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #2b3a8f 0 10px, #24317a 10px 20px);
  color: rgba(255,255,255,.6); font: 700 2rem var(--display);
}
.person .back small { font: 700 .8rem var(--display); color: rgba(255,255,255,.55); margin-top: 2px; }
.person.down .face { transform: rotateY(-180deg); }
.person.down .back { transform: rotateY(0); }
.board.guessing .person:not(.down) { outline: 3px dashed var(--gold); outline-offset: -3px; animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }
.person.wrong { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.person.right { outline: 4px solid var(--green); outline-offset: -4px; }

/* side panel */
.side { display: flex; flex-direction: column; gap: 12px; }
.panel { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.mine { display: flex; align-items: center; gap: 12px; }
.mycard { width: 74px; flex-shrink: 0; border-radius: 10px; overflow: hidden; border: 3px solid var(--gold); background: #fff; }
.mycard svg { display: block; width: 100%; }
.small { margin: 0; color: var(--muted); font-size: .85rem; }
.myname { margin: 0; font: 700 1.6rem/1.1 var(--display); color: var(--gold); }
.cpu-left { margin-left: auto; text-align: center; font-size: .78rem; color: var(--muted); max-width: 90px; line-height: 1.25; }
.cpu-left b { display: block; font: 700 1.6rem var(--display); color: var(--ink); }
.status { font: 600 1.15rem var(--display); margin-bottom: 8px; color: var(--gold); }
.chat { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.chat li { padding: 8px 12px; border-radius: 14px; line-height: 1.35; max-width: 92%; font-size: .98rem; }
.chat li .who { display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.chat li.me { align-self: flex-end; background: #3d7bd9; border-bottom-right-radius: 4px; }
.chat li.cpu { align-self: flex-start; background: #3a4378; border-bottom-left-radius: 4px; }
.chat li.note { align-self: center; background: none; color: var(--muted); font-size: .88rem; text-align: center; padding: 2px 6px; }
.chat li.new { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.label { display: block; font: 600 .8rem var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #141a40; font-weight: 700; font-size: 1rem; }
select:focus { outline: 2px solid var(--gold); }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.tip { margin: 0; line-height: 1.45; }
.tip b { color: var(--gold); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 14px; font-weight: 800; font-size: 1rem; cursor: pointer; min-height: 44px; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: var(--bg); border-color: transparent; box-shadow: 0 4px 0 var(--gold-dark); font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.btn.primary:hover:not(:disabled) { background: #ffd35e; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn.yes { background: var(--green); border-color: transparent; font: 600 1.2rem var(--display); }
.btn.no { background: var(--red); border-color: transparent; font: 600 1.2rem var(--display); }
.btn.wide { width: 100%; margin-top: 12px; }
.linkbtn { background: none; border: 0; color: var(--gold); font-weight: 800; cursor: pointer; margin-top: 12px; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 40, .75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 14px; }
.card { position: relative; width: min(480px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.5); }
.card.center { text-align: center; }
.card h2 { margin: 0 0 6px; font: 700 2rem var(--display); }
.card h3 { margin: 16px 0 6px; font: 600 1.15rem var(--display); color: var(--gold); }
.card p { line-height: 1.5; margin: 0 0 12px; }
.card .big { font-size: 1.06rem; }
.kicker { font: 600 .8rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.kicker a { color: inherit; text-decoration: none; }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.field { margin-bottom: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: rgba(0,0,0,.25); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.2); }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold); flex-shrink: 0; }
.check small { display: block; color: var(--muted); font-size: .86rem; }
.steps { padding-left: 20px; margin: 4px 0; line-height: 1.55; }
.steps li { margin-bottom: 4px; }
.words { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 4px; }
.words b { color: var(--gold); }
.reveal { display: flex; justify-content: center; gap: 16px; margin: 6px 0 10px; }
.reveal figure { margin: 0; width: 120px; }
.reveal figure > div { border-radius: 12px; overflow: hidden; border: 3px solid var(--gold); background: #fff; }
.reveal figure > div svg { display: block; width: 100%; }
.reveal .nm { display: block; font: 700 1.1rem var(--display); color: #1d2452; padding: 2px 0 4px; }
.reveal figcaption { font-size: .82rem; color: var(--muted); margin-top: 4px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 10px 10px 24px; }
  .side { order: -1; }
  .chat { max-height: 150px; }
  .board { grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 9px; border-radius: 16px; }
  .person .face span { font-size: .85rem; }
}
@media (max-width: 480px) {
  .brand .site { display: none; }
  .brand h1 { font-size: 22px; }
  .card { padding: 18px 16px; }
  .mycard { width: 60px; }
  .myname { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
.mycard.wrong { animation: shake .45s; }
