/* Logo palette: navy page, cream surfaces with navy text, orange actions, teal highlights. */
:root { --bg: #14102b; --card: #fff3dc; --ink: #fff3dc; --surface-ink: #14102b; --muted: #b9b3d6; --accent: #ff8a3d; --ok: #3dd6c4; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, sans-serif; background: var(--bg); color: var(--ink);
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
h1 { text-align: center; color: var(--accent); }
button { font: inherit; padding: .4em .8em; border: 1px solid #8f88b0; border-radius: 6px; background: var(--card); color: var(--surface-ink); cursor: pointer; }
@media (hover: hover) { button:hover { background: #f2e0bd; } }
input, select, textarea { font: inherit; width: 100%; padding: .4em; border: 1px solid #8f88b0; border-radius: 6px; background: #fff; color: var(--surface-ink); }
a { color: var(--accent); }
label { display: block; margin: .5em 0; }
.hint { color: var(--muted); font-size: .85em; }
.error { color: var(--accent); min-height: 1.2em; text-align: center; }

#lobby { padding: 16px; position: relative; }
/* Vertical ads in the lobby margins, only where the screen is wide enough to leave the forms clear. */
.side-ad, .feed-ad { display: none; }
@media (min-width: 1100px) {
  .side-ad { display: block; position: absolute; top: 200px; width: 160px; height: 600px; }
  .side-ad.left { left: 24px; }
  .side-ad.right { right: 24px; }
}
.forms { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.forms + .forms { margin-top: 16px; }
.forms form { background: var(--card); color: var(--surface-ink); padding: 16px; border-radius: 10px; width: 320px; max-width: 100%; }

header { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 16px; background: var(--card); color: var(--surface-ink); border-bottom: 1px solid #8f88b0; }
#status { flex: 1; font-weight: 600; }
header.act { background: var(--ok); border-color: var(--ok); }
header.act #status { font-size: 1.2em; }
/* Navy text on orange: white on this orange fails contrast. */
button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface-ink); font-weight: 600; }
@media (hover: hover) { button.primary:hover { background: #ff9f5f; } }
main { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: auto 1fr; grid-template-areas: "board turn" "board side"; gap: 16px; padding: 16px; align-items: start; }
#turn { grid-area: turn; }
#turn .error { margin: 4px 0 0; }
#board { grid-area: board; }
#board .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 12px; }
#board summary { font-weight: 600; text-transform: capitalize; padding: 6px 0; cursor: pointer; }
aside { grid-area: side; }
.game-ad { display: block; width: 100%; height: 250px; margin-top: 12px; }
aside ul, #log { padding-left: 1.2em; }
#log li { margin-bottom: .4em; }
.who { color: var(--surface-ink); font-weight: 700; padding: 0 .35em; border-radius: 4px; white-space: nowrap; }

.card { position: relative; }
.card .face { width: 100%; color: var(--surface-ink); padding: 4px; background: var(--card); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card img { width: 100%; height: 100px; object-fit: contain; }
.card .noimg { height: 100px; display: grid; place-items: center; font-size: 2em; color: #bbb; }
.card .name { font-size: .8em; text-align: center; word-break: break-word; }
.r-common .face { background: #e4e8ec; }
.r-rare .face { background: #fbd9a8; }
.r-epic .face { background: #e3c4f5; }
.r-legendary .face { background: linear-gradient(135deg, #c8f0f7, #f7d4ef, #fff2b8); }
.r-champion .face { background: #f6dc8a; }
.card.down .face { opacity: .25; filter: grayscale(1); }
.card.secret .face { outline: 4px solid var(--ok); outline-offset: 2px; box-shadow: 0 0 14px 4px var(--ok); }
#board .card.secret::before { content: 'Your card'; position: absolute; z-index: 1; top: -9px; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 4px; background: var(--ok); color: var(--surface-ink); font-size: .7em; font-weight: 700; white-space: nowrap; }
.card .info { position: absolute; top: 2px; right: 2px; padding: 0 .45em; font-size: .8em; border-radius: 50%; }
/* The board is rebuilt on each click, so play the second half of a flip on the new card. */
.card.flip { animation: flip .3s ease-out; }
@keyframes flip { from { transform: perspective(400px) rotateY(90deg); } }
@media (prefers-reduced-motion: reduce) { .card.flip { animation: none; } }

#panel { background: var(--card); color: var(--surface-ink); padding: 12px; border-radius: 10px; }
#panel .row { display: flex; gap: 6px; margin: 6px 0; }
#panel .row > * { flex: 1; }
#panel .row > input { flex: 2; }
.you { font-weight: 600; }
.out { color: var(--muted); text-decoration: line-through; }
#panel .hint { color: #5c5675; }
dialog { background: var(--card); color: var(--surface-ink); border: 0; max-width: min(480px, calc(100vw - 32px)); border-radius: 10px; }
#result .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 12px; }

/* Phones: ask panel first so your move isn't under the board, Q&A last, smaller cards, no iOS zoom-on-focus. */
@media (max-width: 700px) {
  header { gap: 8px; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  #status { flex-basis: 100%; order: 1; }
  #leave { margin-left: auto; }
  #lobby { padding-top: max(16px, env(safe-area-inset-top)); }
  main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "turn" "board" "side"; gap: 12px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  #board .grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
  .card img, .card .noimg { height: 72px; }
  .card .info { min-width: 28px; min-height: 28px; }
  input, select, textarea { font-size: 16px; }
  /* In-feed ads size to their content, so no fixed height. */
  .feed-ad { display: block; margin: 16px 0; }
  #game > .feed-ad { margin: 0 8px 8px; }
  aside .feed-ad { margin: 0 0 12px; }
}

footer { padding: 16px; text-align: center; color: var(--muted); font-size: .8em; }
footer a { color: inherit; }
.page { max-width: 680px; margin: 0 auto; padding: 16px; }
.page h1 { text-align: left; }
.logo { display: block; margin: 0 auto; max-width: 60vw; height: auto; border-radius: 16px; }
dialog a { color: var(--surface-ink); }
#info { padding: 0; width: 360px; }
#info .face { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 16px 10px; }
#info img { height: 96px; }
#info h3, #info p { margin: 0; }
#info p { text-transform: capitalize; }
#info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; padding: 12px 16px; }
#info dt { font-weight: 700; }
#info dd { margin: 0; }
#info > a { display: inline-block; margin: 0 16px 16px; }
#info form { float: right; margin: 0 16px 16px; }
dialog::backdrop { background: rgb(20 16 43 / .7); }
/* Faint cream panel so text blocks stand off the navy page. */
.box { background: rgb(255 243 220 / .08); border-radius: 10px; padding: 4px 16px 12px; }
#turn .box { margin-top: 12px; }
#lobby .box { margin-top: 24px; }
.tagline { text-align: center; color: var(--ok); font: clamp(1.6em, 6.5vw, 2.6em)/1.1 'Bungee', system-ui, sans-serif; text-shadow: 0 3px 0 #000; margin: -.25em 0 .75em; }
