/* ===== Phone and tablet: one clean column (the original layout). Order is set per element because the rails
   are flattened with display:contents, so the elements of all three columns share one flex column. ===== */
main { max-width: 640px; margin: auto; padding: 14px 12px }
#game { margin: 12px auto; padding: 18px 14px }
#tools-bar { display: flex; justify-content: flex-end; gap: 8px }
.pc-head { display: block }
.pc-conn { margin: 0 0 8px }
.pc-stage { display: flex; flex-direction: column }
.pc-stage > aside, .pc-stage > section { display: contents }
#setup, #pass { order: 0 } #top { order: 1 } #bar { order: 2 } #banner { order: 3 } #pattern { order: 4 } #pick { order: 5 } #board { order: 6 }
#tools { order: 7 } #guessform { order: 8 } #localbar { order: 9 } #log { order: 10 } #result { order: 11 } #solo { order: 12 } .pc-foot { order: 13 }
.pc-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-weight: 800; margin-top: 6px }
.pc-timer { font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.5rem; color: var(--lg-rose); font-variant-numeric: tabular-nums }
.pc-timer[data-low=true] { color: var(--lg-bad); animation: pc-pulse 1s ease-in-out infinite }
@keyframes pc-pulse { 50% { transform: scale(1.12) } }
.pc-player + .pc-sep + .pc-player { margin-left: 0 }
.pc-who { font-weight: 800 }
.pc-bar { height: 8px; background: var(--lg-pink); border-radius: 99px; overflow: hidden; margin: 6px 0 }
#barfill { height: 100%; width: 100%; background: var(--lg-rose); transition: width .2s linear }
.pc-banner { font-weight: 800; font-size: 1.1rem; margin: 8px 0 4px; min-height: 1.6em }
.pc-banner b { font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.5rem; color: var(--lg-rose); letter-spacing: .04em }
.pc-pattern { font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.6rem; letter-spacing: .12em; margin: 2px 0 8px; overflow-wrap: anywhere }
/* the paper stays white in every theme: the eraser paints white and strokes are picked for white */
.pc-paper { border: 3px solid var(--lg-line); border-radius: 16px; overflow: hidden; background: #fff; line-height: 0; box-shadow: 0 6px 18px -8px #53223f40 }
#canvas { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; background: #fff }
#canvas.can-draw { touch-action: none; cursor: crosshair }
.pc-tools { margin: 10px 0 }
.pc-h { font-family: 'Nunito', system-ui, sans-serif; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--lg-muted); margin: 0 0 8px; font-weight: 800 }
.pc-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 }
.pc-colour { position: relative; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; border: 3px solid var(--lg-white); box-shadow: 0 0 0 2px var(--lg-line), 0 3px 0 #0002; color: #fff; font-weight: 800; font-size: 1.2rem; line-height: 1; transition: transform .15s ease }
.pc-colour:hover { transform: translateY(-2px) scale(1.06) }
.pc-colour:active { transform: translateY(1px) scale(.96) }
.pc-colour[aria-pressed=true] { box-shadow: 0 0 0 3px var(--lg-ink), 0 3px 0 #0002 }
.pc-colour[aria-pressed=false] .tick { display: none }
.pc-colour.light { color: #2b1f26 }
.pc-size { width: 52px; height: 52px; min-height: 44px; padding: 0; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 var(--lg-line); transition: transform .15s ease, box-shadow .15s ease }
.pc-size:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lg-line) }
.pc-size[aria-pressed=true], #eraser[aria-pressed=true] { background: var(--lg-pink); border-color: var(--lg-rose); box-shadow: 0 0 0 2px var(--lg-rose) inset }
.pc-size i { display: block; background: var(--brush, var(--lg-ink)); border-radius: 50%; box-shadow: 0 0 0 1px #0003 }
.pc-brushes.erasing .pc-size i { background: #fff; box-shadow: 0 0 0 1.5px var(--lg-muted) }
.pc-actions .lg-button { box-shadow: 0 3px 0 var(--lg-line) }
.pc-actions .lg-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lg-line) }
.pc-howto { display: none }
.pc-keys { font-size: .78rem; line-height: 1.9; margin: 6px 0 0 }
kbd { font: 800 .74rem/1 'Nunito', system-ui, sans-serif; padding: 2px 6px; border: 1px solid var(--lg-line); border-bottom-width: 2px; border-radius: 6px; background: var(--lg-cream); color: var(--lg-ink) }
.pc-guess { margin: 12px 0 }
.pc-guess label { display: block; font-weight: 800; margin-bottom: 6px }
.pc-guess .lg-row { flex-wrap: nowrap }
.pc-guess input { flex: 1; min-width: 0; min-height: 48px; border: 1px solid var(--lg-line); border-radius: 12px; background: var(--lg-cream); padding: 10px; color: var(--lg-ink); font-size: 1.1rem }
.pc-log { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; max-height: 9.5em; overflow-y: auto }
.pc-log li { padding: 4px 10px; border-radius: 10px; background: var(--lg-cream); font-weight: 700; overflow-wrap: anywhere }
.pc-log li.ok { background: var(--lg-tint-2); color: var(--lg-good) }
.pc-log li.close { background: var(--lg-tint-1); color: var(--lg-warn) }
.pc-result { text-align: center; margin: 10px 0; padding: 10px; border-radius: 16px; background: var(--lg-cream); animation: pc-pop .35s cubic-bezier(.34, 1.56, .64, 1) }
@keyframes pc-pop { from { transform: scale(.94); opacity: 0 } }
.pc-result .lg-row { justify-content: center }
.pc-solo { margin-top: 12px }
.pc-setup { display: grid; gap: 10px; margin: 10px 0 }
.pc-setup label { display: grid; gap: 4px; font-weight: 800 }
.pc-setup input { min-height: 48px; border: 1px solid var(--lg-line); border-radius: 12px; background: var(--lg-cream); padding: 10px; color: var(--lg-ink); font-size: 1.1rem }
.pc-setup .lg-row { justify-content: center }
.pc-pass { text-align: center; margin: 14px 0; padding: 26px 14px; border-radius: 20px; background: var(--lg-pink); display: grid; gap: 10px; justify-items: center }
.pc-pass-big { font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.7rem; margin: 0; overflow-wrap: anywhere }
.pc-pass button { min-height: 52px; font-size: 1.05rem }
.pc-pick { text-align: center; margin: 10px 0 }
.pc-pick-title { font-weight: 800; font-size: 1.1rem; margin: 0 0 8px }
.pc-words { display: grid; gap: 8px }
.pc-words button { min-height: 56px; font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.3rem; text-transform: uppercase; letter-spacing: .04em; box-shadow: 0 3px 0 var(--lg-line); transition: transform .15s ease }
.pc-words button:hover { transform: translateY(-2px) }
.pc-words small { display: block; font-family: 'Nunito', system-ui, sans-serif; font-size: .7rem; text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--lg-muted) }
.pc-localbar { justify-content: center; margin: 10px 0 }
.pc-saved { margin-top: 12px }
.pc-saved img { max-width: 100%; height: auto; border: 3px solid var(--lg-line); border-radius: 12px; background: #fff }
.pc-foot { text-align: center; margin: 16px 0 0 }
/* lobby: avatars in even rows and the three buttons side by side (the lobby markup is shared, so this is scoped to this page) */
#lobby .lg-avatar-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) }
#lobby .lg-avatar { width: 100%; height: 46px }
#lobby .lg-lobby > .lg-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) }
@media (max-width: 420px) {
  main { padding: 8px 6px }
  #game { padding: 14px 10px }
  .pc-group { gap: 6px }
  .pc-colour { width: 40px; height: 40px; min-height: 40px }
}

/* ===== PC and laptop (1000px and wider): a no-scroll studio. Tool dock | big canvas | scores and guess feed. ===== */
@media (min-width: 1000px) {
  :root { --lg-stage-max: 1360px }
  body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden }
  main { flex: 1; min-height: 0; max-width: none; width: 100%; margin: 0; padding: 0; display: flex; flex-direction: column; position: relative }
  #tools-bar { position: absolute; top: 10px; right: max(24px, calc((100vw - var(--lg-stage-max)) / 2 + 24px)); z-index: 5 }
  #lobby { flex: 1; min-height: 0; overflow: auto; padding-top: 4px }
  #lobby .lg-lobby { max-width: 620px; margin: 8px auto }
  #game { flex: 1; min-height: 0; width: 100%; max-width: var(--lg-stage-max); margin: 0 auto; padding: 10px 0 0; display: flex; flex-direction: column; background: transparent; border: 0; box-shadow: none; border-radius: 0 }
  .pc-head { display: flex; align-items: center; gap: 18px; padding: 0 24px 8px; min-height: 48px; padding-right: 90px }
  .pc-head h1 { margin: 0; font-size: 1.6rem }
  .pc-conn { margin: 0 }
  .pc-stage.lg-stage { display: grid; flex: 1; height: auto; min-height: 0; padding: 0 24px 18px; grid-template-columns: 232px minmax(0, 1fr) 272px; max-width: none; width: 100%; box-sizing: border-box }
  .pc-stage > aside { display: flex }
  .pc-stage > section { display: flex }
  /* an empty rail keeps its place (so the centre does not slide) but is not drawn */
  .pc-dock:not(:has(> :not([hidden]))), .pc-side:not(:has(> :not([hidden]):not(.pc-foot))) { visibility: hidden }
  .pc-centre { gap: 10px; justify-content: flex-start; padding: 2px 8px 10px }
  #setup, #pass, #pick, #result { order: 0; width: 100%; max-width: 560px }
  #setup, #pass, #pick { margin-top: auto; margin-bottom: auto }
  #banner { order: 1; margin: 2px 0 0; text-align: center; min-height: 1.5em }
  #pattern { order: 2; margin: 0; text-align: center }
  #board { order: 3; flex: 1 1 0; min-height: 0; width: 100%; container-type: size; display: grid; place-items: center }
  .pc-paper { width: min(100cqw, calc((100cqh - 2px) * 4 / 3)) }
  #result { order: 4; margin: auto 0; padding: 8px 14px } #result h2 { margin: 0; font-size: 1.15rem } #result p { margin: 2px 0 }
  #localbar { order: 5; margin: 0 }
  .pc-dock { padding: 16px }
  .pc-dock:has(#tools[hidden]) .pc-howto { display: block }
  .pc-howto h2 { font-size: 1.05rem; margin: 0 0 10px }
  .pc-howto ol { margin: 0; padding-left: 1.2em; display: grid; gap: 10px; font-weight: 700; font-size: .92rem; line-height: 1.4 }
  .pc-tools { margin: 0 }
  .pc-swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); justify-items: center; gap: 8px; margin: 0 0 14px }
  .pc-brushes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px }
  .pc-size { width: 100%; height: 56px }
  .pc-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 12px }
  .pc-actions .lg-button { width: 100%; justify-content: flex-start; padding-left: 16px }
  .pc-actions .lg-button:hover:not(:disabled), .pc-size:hover, #lobby .lg-button:hover:not(:disabled) { border-color: var(--lg-rose) }
  #eraser::before { content: '⌫'; font-size: 1.1rem } #undo::before { content: '↶'; font-size: 1.2rem } #clear::before { content: '✕'; font-size: 1rem }
  .pc-side { gap: 12px }
  #top { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; margin: 0 }
  .pc-round { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--lg-muted) }
  .pc-timer { font-size: 2.3rem; line-height: 1; text-align: right }
  .pc-scores { grid-column: 1 / -1; display: grid; gap: 6px }
  .pc-sep { display: none }
  .pc-player { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 14px; background: var(--lg-cream); border: 2px solid transparent; font-size: 1rem }
  .pc-player b { font-family: 'Fredoka', system-ui, sans-serif; font-size: 1.4rem; color: var(--lg-rose) }
  .pc-player[data-drawing=true] { border-color: var(--lg-rose); background: var(--lg-pink) }
  .pc-player[data-drawing=true] .pc-who::after { content: '✎ drawing'; margin-left: 8px; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--lg-rose) }
  #top { order: 0 } #bar { order: 1; margin: 0; height: 10px }
  #log { order: 2; flex: 1 1 0; min-height: 60px; max-height: none; margin: 0; align-content: start; padding: 2px }
  .pc-side:has(#guessform:not([hidden])) #log:empty::before { content: 'Guesses will show up here.'; color: var(--lg-muted); font-weight: 700; font-size: .9rem; padding: 8px 4px }
  #guessform { order: 3; margin: 0 }
  #solo { order: 4; margin: 0 } .pc-solo .lg-row { flex-direction: column; flex-wrap: nowrap } .pc-solo .lg-row .lg-button { width: 100% }
  .pc-side:has(#solo:not([hidden])) #log { display: none }
  .pc-tip { margin: 0 0 10px; font-size: .88rem }
  .pc-foot { order: 5; margin: auto 0 0; text-align: left; font-size: .9rem }
  .pc-saved img { width: 100% }
}
@media (min-width: 1700px) {
  :root { --lg-stage-max: 1800px }
  .pc-stage.lg-stage { grid-template-columns: 270px minmax(0, 1fr) 320px }
}
@media (min-width: 1000px) {
  #result:has(#over-actions:not([hidden])) { padding: 28px 22px; background: var(--lg-pink) }
  #result:has(#over-actions:not([hidden])) h2 { font-size: 2rem }
  #result:has(#over-actions:not([hidden])) p { font-size: 1.05rem }
}
