@layer base, components;
@layer base {
  :root { font-family: system-ui, sans-serif; color: #26251f; background: #f7f4eb; color-scheme: light; --ink: #26251f; --muted: #625e52; --paper: #fffdf7; --line: #dcd5c6; --red: #a23528; --soft: #f0e9d8; }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; }
  :focus-visible { outline: 3px solid #a23528; outline-offset: 4px; }
  a { color: inherit; }
  h1, h2, p, ul, ol { margin: 0; }
  h1 { font: 500 clamp(2.3rem, 6.6vw, 5.25rem)/.99 Georgia, serif; letter-spacing: -.065em; }
  h1 em { color: var(--red); font-weight: inherit; }
  h2 { font-size: 1.02rem; }
  p { line-height: 1.5; }
  button, input, .button { font: inherit; }
  button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .8rem; min-height: 2.9rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--paper); color: var(--ink); padding: .6rem .9rem; cursor: pointer; text-decoration: none; font-weight: 650; }
  button:hover, .button:hover { background: var(--soft); }
  button:disabled { opacity: .48; cursor: default; }
  input { width: 100%; min-height: 2.9rem; padding: .6rem .75rem; border-radius: .55rem; border: 1px solid #bfb6a6; background: var(--paper); color: var(--ink); }
}
@layer components {
  .top, footer, main { width: min(87rem, calc(100% - 2.4rem)); margin-inline: auto; }
  .top, footer { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 0; border-bottom: 1px solid var(--line); gap: 1rem; }
  .brand { display: inline-flex; align-items: center; font: bold 1.55rem Georgia, serif; text-decoration: none; }
  .dot { color: var(--red); }
  .brand-pin { display: inline-block; border: 2px solid var(--red); width: 15px; height: 15px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); margin: 0 .55rem .2rem .1rem; }
  .brand-pin::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--red); }
  .connection { color: var(--muted); font-size: .83rem; display: flex; align-items: center; gap: .45rem; }
  .connection i { width: .5rem; height: .5rem; border-radius: 50%; background: #af6f30; }
  .connection.online i { background: #547449; }
  main { flex: 1; padding: clamp(1.3rem, 5vw, 4rem) 0 2rem; }
  main:has(#play:not([hidden]), #results:not([hidden])) { padding-top: clamp(.75rem, 2.4vh, 1.6rem); }
  footer { border-bottom: 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
  .entry { display: grid; max-width: 58rem; margin: clamp(1rem, 8vh, 6rem) auto; grid-template-columns: 1.2fr 1fr; align-items: center; gap: clamp(1.6rem, 6vw, 5rem); }
  .intro h1 { font-size: clamp(3.6rem, 10vw, 7.4rem); }
  .intro > p:last-child { color: var(--muted); margin-top: 1.25rem; max-width: 28ch; }
  .kicker { margin-bottom: .65rem; text-transform: uppercase; font-size: .72rem; letter-spacing: .13em; font-weight: 760; color: var(--muted); }
  .panel { background: var(--paper); border: 1px solid var(--line); border-radius: .95rem; }
  .entry-form, .guess, .summary { display: grid; align-content: start; gap: .85rem; padding: 1rem; }
  .entry-form label { display: grid; gap: .35rem; font-size: .86rem; font-weight: 650; }
  .settings { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
  .primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  .primary:hover { background: #453f35; }
  .stage { animation: arrive .3s ease-out both; }
  #lobby { max-width: 55rem; margin-inline: auto; padding: clamp(1rem, 4vw, 2.5rem); }
  #lobby-settings { margin-top: .9rem; color: var(--muted); }
  .actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1.35rem 0; }
  .lobby-members { border-top: 1px solid var(--line); padding-top: 1rem; }
  #players { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: .65rem 0 0; }
  #players li { background: var(--soft); padding: .35rem .6rem; border-radius: .45rem; overflow-wrap: anywhere; }
  .usage-link { display: inline-block; margin-top: 1rem; color: var(--muted); font-size: .82rem; text-underline-offset: .16em; }
  .round-bar { display: flex; justify-content: space-between; align-items: end; gap: .9rem; margin-bottom: 1.1rem; }
  .round-bar h1 { font-size: clamp(2.15rem, 5.8vw, 4.35rem); }
  #play .round-bar h1 { font-size: clamp(2.15rem, 4vw, 3.45rem); }
  .round-meta { display: flex; align-items: center; gap: .55rem; }
  .clock { position: relative; overflow: hidden; font: 700 clamp(1.15rem, 4vw, 1.8rem)/1 ui-monospace, monospace; background: var(--paper); border: 1px solid var(--line); padding: .7rem; border-radius: .65rem; white-space: nowrap; }
  .clock i { position: absolute; inset: auto 0 0; height: 3px; transform-origin: left; background: #628075; transition: transform .23s linear; }
  .clock.urgent { color: var(--red); }
  .clock.urgent i { background: var(--red); }
  .multiplier { display: inline-flex; align-items: center; padding: .45rem .6rem; border: 1px solid #e1bb75; background: #ffe9bb; color: #6d3918; font-size: .82rem; font-weight: 800; border-radius: 1rem; white-space: nowrap; animation: multiplier-in .54s cubic-bezier(.22,.75,.2,1) both; }
  .double-round .kicker { color: #8b4e22; }
  .double-round .scene, .double-round .guess { border-color: #d7a85e; }
  .board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: .85rem; }
  .scene { min-height: clamp(17rem, 50vh, 36rem); position: relative; overflow: hidden; background: #eadcc3; display: grid; align-items: center; }
  .scene-status { position: relative; margin: 1rem; padding: .7rem; background: var(--paper); border-radius: .5rem; }
  .scene-render { position: absolute; inset: 0; }
  .scene-viewer { width: 100%; height: 100%; }
  .guess-controls p, .round-footer, .summary p { color: var(--muted); font-size: .87rem; }
  .guess { grid-template-rows: minmax(0, 1fr) auto; align-content: stretch; padding: .5rem; gap: .5rem; }
  .guess-controls { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .1rem .15rem; }
  .guess-controls button { white-space: nowrap; }
  .map { height: clamp(15rem, 35vh, 24rem); position: relative; z-index: 0; background: #eae7d8; overflow: hidden; border-radius: .6rem; }
  .guess .map { height: clamp(20rem, 55dvh, 39rem); cursor: crosshair; }
  .map:focus-visible { outline-offset: -3px; }
  .mapy-logo { position: absolute; left: .35rem; bottom: .35rem; z-index: 700; display: grid; }
  .mapy-logo img { height: 30px; width: auto; }
  .person-pin { display: block; width: 100%; height: 100%; overflow: visible; color: #ad3527; filter: drop-shadow(0 2px 2px #241d1666); }
  .person-pin path { fill: currentColor; stroke: #fffdf7; stroke-width: 1.5; }
  .person-pin circle { fill: #fffdf7; }
  .target-pin { color: #234941; }
  .round-footer { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .6rem; }
  .round-footer button { min-height: 2rem; font-size: .8rem; }
  .result-board { grid-template-columns: minmax(0, 1.55fr) minmax(11rem, 1fr); }
  .summary { position: relative; isolation: isolate; overflow: hidden; align-content: center; justify-items: center; text-align: center; }
  .summary strong { font: 500 clamp(2.7rem, 7vw, 5rem)/1 Georgia, serif; color: var(--red); font-variant-numeric: lining-nums tabular-nums; }
  .double-round .summary { background: radial-gradient(ellipse at 50% 42%, #ffedc9, var(--paper) 74%); border-color: #e1bb75; }
  .summary .score-multiplier { z-index: 1; color: #6d3918; font-weight: 750; font-variant-numeric: tabular-nums; background: #ffe6ad; padding: .25rem .65rem; border-radius: 1rem; }
  .rankings { max-width: 62rem; margin: 1.15rem auto; padding: .85rem 1rem; }
  .rankings ol { position: relative; isolation: isolate; list-style: none; padding: .5rem 0 0; }
  .rankings li { position: relative; display: grid; grid-template-columns: 3ch minmax(0, 1fr) 4ch minmax(6ch, auto); align-items: center; gap: .65rem; min-height: 2.65rem; padding: .25rem .45rem; border-top: 1px solid var(--line); background: var(--paper); font-variant-numeric: tabular-nums; }
  .rankings li.self { z-index: 1; color: var(--red); background: #f9ede3; }
  .place { color: var(--muted); }
  .rankings li span:nth-child(2) { overflow-wrap: anywhere; }
  .rankings li strong, .movement { text-align: right; }
  .movement { color: var(--muted); font-size: .8rem; }
  .final { position: relative; isolation: isolate; overflow: hidden; text-align: center; padding: clamp(1rem, 4vw, 2.5rem) 0 .6rem; }
  .final h1, .final .button { position: relative; }
  .podium { list-style: none; margin: 1.65rem auto 1.2rem; padding: 0 .25rem; display: flex; align-items: end; justify-content: center; gap: clamp(.3rem, 1.5vw, .8rem); }
  .podium li { position: relative; display: grid; align-content: center; gap: .4rem; background: var(--paper); border: 1px solid var(--line); border-radius: .75rem; padding: .7rem .45rem; width: min(31%, 12rem); min-height: 6.5rem; overflow-wrap: anywhere; animation: podium-rise .65s cubic-bezier(.19,.8,.24,1) backwards; animation-delay: var(--podium-delay); }
  .podium li:nth-child(1) { order: 2; min-height: 9rem; }
  .podium li:nth-child(2) { order: 1; min-height: 7.6rem; }
  .podium li:nth-child(3) { order: 3; }
  .podium li[data-rank="1"] { border-color: #e1bb75; background: #ffeac0; color: #6d3918; }
  .podium b { font: 500 clamp(1.8rem, 5vw, 3.25rem)/1 Georgia, serif; }
  .podium span { font-size: .82rem; font-variant-numeric: tabular-nums; }
  .effects { position: absolute; inset: 0; pointer-events: none; }
  .effects i { position: absolute; top: 47%; left: 50%; width: .36rem; height: .62rem; border-radius: 2px; background: var(--tone); animation: confetti-out 1.15s cubic-bezier(.18,.68,.28,1) both; }
  .effects i:nth-child(3n) { width: .45rem; height: .45rem; border-radius: 50%; }
  .error { margin-top: 1rem; color: var(--red); }
  .map-line { stroke-dasharray: 7 4; animation: dash .6s ease-out both; }
  @keyframes dash { from { stroke-dashoffset: 30; opacity: 0; } }
  @keyframes arrive { from { transform: translateY(7px); opacity: 0; } }
  @keyframes multiplier-in { from { transform: scale(.8); opacity: 0; } 64% { transform: scale(1.07); } }
  @keyframes podium-rise { from { transform: translateY(26px) scale(.96); opacity: 0; } }
  @keyframes confetti-out {
    from { transform: translate(0, 0) rotate(0) scale(.35); opacity: 0; }
    14% { opacity: .95; }
    to { transform: translate(var(--x), calc(var(--y) + 30px)) rotate(var(--spin)) scale(.85); opacity: 0; }
  }
  @media (max-width: 720px) {
    .top, footer, main { width: calc(100% - 1.3rem); }
    .entry, .board, .result-board { grid-template-columns: 1fr; }
    .entry { margin: 1.3rem 0; }
    .scene { min-height: clamp(10rem, 28dvh, 18rem); }
    .guess .map { height: clamp(12rem, 32dvh, 20rem); }
    .board { gap: .55rem; }
    .round-bar { align-items: start; }
    .round-meta { gap: .3rem; }
    .round-bar button { font-size: .83rem; }
    .result-board .summary { grid-row: 1; padding: .65rem; gap: .3rem; }
    .guess-controls p { font-size: .8rem; }
    .guess-controls button { font-size: .83rem; min-height: 2.6rem; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
}
