@import url("./tokens.css");
/* Hallmark · genre: playful · macrostructure: bespoke portrait game console
 * theme: Hum-inspired cream / orange · native physics + short UI feedback */
* { box-sizing: border-box; }
body { margin: 0; background: #eee5d5; color: var(--ink); overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; transition: transform .15s var(--ease), background .15s; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
button:active { transform: scale(.94); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.game-shell { width: 100%; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 20px max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; background: var(--paper); overflow: hidden; }
.masthead { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; height: 50px; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 850; letter-spacing: -.8px; line-height: 1.2; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 40px; background: #ed9656; color: #fff9ed; border-radius: 14px 14px 14px 5px; transform: rotate(-8deg); }
.brand-mark svg { width: 27px; height: 27px; fill: currentColor; stroke: none; transform: rotate(8deg); }
.brand-tag { display: block; font-size: 8px; letter-spacing: 1.8px; font-weight: 650; margin-top: 5px; color: var(--muted); }
.header-actions { display: flex; gap: 6px; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); background: transparent; border-radius: 50%; display: grid; place-items: center; }
.icon-button svg { width: 21px; height: 21px; }
.icon-button[aria-pressed="true"] { background: #f6e3c9; }
.dashboard { display: flex; align-items: center; padding: 15px 1px 17px; flex-shrink: 0; gap: 20px; }
.eyebrow { display: flex; align-items: center; gap: 3px; font-size: 10px; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.score-block { min-width: 88px; }
.score-number { display: inline-block; font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif; font-size: 42px; line-height: 1.1; font-weight: 850; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.score-number.pop { animation: score-pop .25s var(--ease); }
.record-number { display: block; font-size: 24px; line-height: 1.4; font-weight: 700; font-variant-numeric: tabular-nums; }
.tiny-icon { width: 14px; height: 14px; }
.next-block { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.next-portrait { width: 48px; height: 48px; position: relative; border-radius: 50%; background: #fffaf0; border: 2px solid #ead9b8; padding: 3px; }
.next-portrait img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.next-spark { position: absolute; right: -4px; bottom: -2px; color: var(--orange); font-size: 18px; text-shadow: 0 0 3px var(--paper); }
.playfield-slot { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.playfield { position: relative; flex: none; width: 100%; height: 100%; min-height: 0; isolation: isolate; border: 2px solid #d7bd90; border-bottom-width: 5px; border-radius: var(--radius-field); background: #fffaf0; box-shadow: 0 4px 0 #e9dcc4; overflow: hidden; touch-action: none; user-select: none; }
.field-heading { position: absolute; left: calc(17px * var(--field-scale, 1)); right: calc(17px * var(--field-scale, 1)); top: calc(14px * var(--field-scale, 1)); display: flex; align-items: center; justify-content: space-between; z-index: 1; pointer-events: none; }
.field-title { font-size: calc(13px * var(--field-scale, 1)); font-weight: 750; color: #aa8760; }
.field-subtitle { font-size: calc(9px * var(--field-scale, 1)); letter-spacing: .5px; color: #b3a18a; }
#game-canvas { width: 100%; height: 100%; display: block; touch-action: none; outline-offset: -4px; }
.drop-hint { position: absolute; top: 32%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; color: #b39b79; font-size: 12px; transition: opacity .3s; }
.drag-hand { font-family: system-ui; font-size: 34px; color: #c8ae89; font-weight: 300; }
.drop-hint.hidden { opacity: 0; }
.field-floor { position: absolute; bottom: 0; left: 0; right: 0; height: calc(29px * var(--field-scale, 1)); display: flex; align-items: center; justify-content: center; gap: calc(12px * var(--field-scale, 1)); background: #f0dfbe; border-top: 1px solid #dec49c; color: #b4976d; font-size: calc(9px * var(--field-scale, 1)); letter-spacing: calc(2px * var(--field-scale, 1)); pointer-events: none; }
.field-floor svg { fill: currentColor; stroke: none; width: calc(13px * var(--field-scale, 1)); height: calc(13px * var(--field-scale, 1)); transform: rotate(-18deg); }
.field-floor svg:last-child { transform: rotate(18deg); }
.toast { position: absolute; left: 50%; top: 104px; transform: translate(-50%, -8px); opacity: 0; padding: 8px 15px; border-radius: 20px; background: #67513eee; color: #fff7e9; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 3; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.game-footer { flex-shrink: 0; padding: 16px 0 0; }
.evolution-heading { display: flex; align-items: center; justify-content: space-between; }
.collection-button, .restart-button { min-height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; }
.collection-button svg { width: 15px; height: 15px; color: #a98c6c; }
.restart-button { color: var(--muted); padding: 0 7px; }
.restart-button svg { width: 13px; height: 13px; }
.evolution-strip { display: flex; align-items: center; justify-content: space-between; gap: 2px; height: 39px; }
.evolution-cat { flex: 1; min-width: 0; position: relative; display: flex; justify-content: center; align-items: center; }
.evolution-cat img { width: var(--size); height: var(--size); object-fit: cover; border-radius: 50%; border: 1.5px solid #d5c2a5; transition: opacity .3s; }
.evolution-cat.locked img { opacity: .42; filter: saturate(.55); }
.evolution-cat.current img { border: 2px solid var(--orange); box-shadow: 0 0 0 2px #f3dfc4; }
.evolution-cat:last-child::after { content: '♛'; position: absolute; font-size: 15px; color: var(--orange-dark); top: -11px; right: 1px; transform: rotate(16deg); }
.footer-note { display: flex; justify-content: space-between; font-size: 8px; letter-spacing: .35px; color: #b6a48c; margin: 9px 0 2px; }
.loading { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; background: #fffaf0; z-index: 5; font-size: 12px; }
.loading[hidden] { display: none; }
.loading-paw svg { width: 40px; height: 40px; fill: #e58a47; stroke: none; animation: score-pop .8s infinite alternate; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: #49382c70; backdrop-filter: blur(5px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(100%, 370px); max-height: min(88dvh, 720px); overflow-y: auto; position: relative; background: var(--paper); border: 1px solid #fff7eb; border-radius: 28px; padding: 30px 24px 24px; box-shadow: 0 16px 64px #3c2c3520; animation: modal-in .22s var(--ease); }
.modal-close { position: absolute; right: 12px; top: 12px; width: 44px; height: 44px; z-index: 1; }
.modal h2 { font-size: 25px; letter-spacing: -1px; margin: 15px 0 10px; }
.modal p { font-size: 12px; line-height: 1.9; color: #9a836b; margin: 8px 0 20px; }
.modal-kicker { color: var(--orange-dark); font-size: 10px; letter-spacing: 2px; font-weight: 700; }
.modal-mascot { width: 84px; height: 84px; object-fit: cover; border: 5px solid #ead8bc; border-radius: 50%; display: block; margin: 8px auto 16px; transform: rotate(-8deg); }
.modal.centered { text-align: center; }
.primary-button, .secondary-button { width: 100%; min-height: 48px; display: block; border-radius: 14px; font-weight: 750; font-size: 14px; margin-top: 16px; }
.primary-button { background: var(--orange); color: #fffaf0; border: 1px solid var(--orange-dark); box-shadow: 0 3px 0 #bd6f37; }
.secondary-button { background: transparent; border: 1px solid var(--line); margin-top: 10px; }
.final-score { font-size: 60px; font-weight: 850; letter-spacing: -2px; line-height: 1.2; }
.final-best { color: var(--orange-dark); font-size: 11px; margin: 8px 0 20px; }
.collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 10px; margin: 24px 0; }
.collection-item img { width: 62px; height: 62px; object-fit: cover; border-radius: 50%; border: 3px solid #dfc7a5; }
.collection-item.locked img { filter: grayscale(.7); opacity: .5; }
.collection-item strong { display: block; margin-top: 5px; font-size: 11px; }
.collection-item small { display: block; font-size: 9px; color: var(--muted); margin-top: 4px; }
.landscape-message { display: none; }
@keyframes score-pop { 50% { transform: scale(1.12); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@media (max-height: 700px) {
  .game-shell { padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  .masthead { height: 44px; }
  .dashboard { padding: 9px 1px 11px; }
  .score-number { font-size: 35px; }
  .game-footer { padding-top: 9px; }
  .footer-note { margin-top: 5px; }
}
@media (max-width: 350px) {
  .game-shell { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 19px; gap: 7px; }
  .brand-tag { font-size: 7px; letter-spacing: 1.3px; }
  .header-actions { gap: 3px; }
  .dashboard { gap: 12px; }
  .score-block { min-width: 72px; }
  .next-block { gap: 5px; }
  .field-subtitle { font-size: calc(8px * var(--field-scale, 1)); }
  .footer-note { font-size: 7px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .game-shell { visibility: hidden; }
  .landscape-message { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--paper); }
  .landscape-message svg { width: 48px; height: 48px; fill: var(--orange); stroke: none; }
  .landscape-message h2 { font-size: 22px; margin-bottom: 6px; }
  .landscape-message p { font-size: 13px; color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

[hidden] { display: none !important; }

/* Four-column portrait scoreboard: personal and server records remain separate. */
.dashboard { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 8px; }
.score-block, .record-block { min-width: 0; }
.dashboard .eyebrow { font-size: 9px; letter-spacing: 0; white-space: nowrap; gap: 2px; }
/* Fixed line heights keep score fitting from changing the board layout. */
.dashboard .score-number { display: block; font-size: var(--score-font-size, 35px); line-height: 38.5px; letter-spacing: -.9px; white-space: nowrap; }
.dashboard .record-number { font-size: var(--score-font-size, 20px); line-height: 28px; white-space: nowrap; }
.dashboard .tiny-icon { width: 11px; height: 11px; flex-shrink: 0; }
.dashboard .next-block { margin-left: 0; flex-direction: column; gap: 3px; }
.dashboard .next-portrait { width: 40px; height: 40px; }
.server-record .record-number { color: var(--orange-dark); }
.record-status { width: 4px; height: 4px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.server-record[data-status="offline"] .record-status { background: #c56e57; }
.server-record[data-status="offline"] .record-number { opacity: .55; }
@media (max-width: 350px) {
  .dashboard { gap: 5px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .dashboard .score-number { font-size: var(--score-font-size, 30px); line-height: 33px; }
  .dashboard .record-number { font-size: var(--score-font-size, 18px); line-height: 25.2px; }
  .dashboard .eyebrow { font-size: 8px; }
}

/* Named global record: reserve its line so updates never change board capacity. */
.record-nickname { display: block; min-width: 0; max-width: 100%; height: 14px; line-height: 14px; font-size: 9px; color: var(--orange-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-record[data-status="offline"] .record-nickname { opacity: .55; }
.nickname-backdrop { z-index: 30; }
.nickname-label { display: block; font-size: 12px; font-weight: 650; margin-bottom: 8px; }
.nickname-input { width: 100%; min-width: 0; min-height: 48px; border: 1px solid #c4a37b; border-radius: 12px; background: #fffaf0; color: var(--ink); font: inherit; font-size: 16px; padding: 12px; }
.nickname-input:hover { border-color: var(--orange-dark); }
.nickname-input:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.nickname-input[aria-invalid="true"] { border-color: #a93f2d; }
.modal .nickname-error { min-height: 18px; margin: 6px 0 0; color: #a93f2d; font-size: 11px; line-height: 1.6; }
.nickname-backdrop .primary-button:hover { background: var(--orange-dark); }

/* Local nickname control lives beside sound, without shrinking the game board. */
.header-actions { flex-shrink: 0; }
.nickname-button { max-width: 88px; min-width: 0; min-height: 44px; padding: 0 9px; border: 1px solid var(--line); border-radius: 14px; background: transparent; font-size: 11px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.nickname-button:hover { background: #f6e3c9; }
@media (max-width: 350px) { .nickname-button { max-width: 70px; padding: 0 6px; } }
@media (max-width: 300px) {
  .brand { font-size: 17px; gap: 5px; }
  .brand-mark { width: 30px; height: 34px; }
  .nickname-button { max-width: 65px; }
}

/* Small inline entry shares the existing nickname row; board size stays unchanged. */
.record-details { display: flex; align-items: center; gap: 4px; height: 14px; min-width: 0; }
.record-details .record-nickname { flex: 1; }
.leaderboard-button { flex-shrink: 0; border: 0; background: transparent; color: var(--orange-dark); padding: 0; height: 14px; line-height: 14px; font-size: 9px; text-decoration: underline; text-underline-offset: 2px; }
.leaderboard-button:hover { color: var(--ink); }
.leaderboard-head, .leaderboard-row { display: grid; grid-template-columns: 32px minmax(0, 1.1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.leaderboard-head { padding: 0 8px 8px; border-bottom: 1px solid var(--line); font-size: 10px; color: var(--muted); }
.leaderboard-head span:last-child { text-align: right; }
.leaderboard-list { list-style: none; margin: 0; padding: 0; }
.leaderboard-row { min-height: 42px; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 12px; border-radius: 6px; }
.leaderboard-row.is-me { background: #f6e3c9; }
.leaderboard-rank { color: var(--orange-dark); font-weight: 750; font-variant-numeric: tabular-nums; }
.leaderboard-name { min-width: 0; overflow-wrap: anywhere; }
.leaderboard-score { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 350px) { .leaderboard-row, .leaderboard-head { grid-template-columns: 26px minmax(0, 1.1fr) minmax(0, 1fr); gap: 5px; } .leaderboard-score { font-size: 11px; } }

/* Only the current page scrolls; the two paging buttons never leave the screen. */
.modal.leaderboard-modal { height: min(88vh, 720px); height: min(88dvh, 720px); overflow: hidden; display: flex; flex-direction: column; }
.leaderboard-modal #modal-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.leaderboard-heading, .leaderboard-modal .leaderboard-head, .leaderboard-footer { flex-shrink: 0; }
.leaderboard-heading { padding-right: 26px; }
.leaderboard-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.leaderboard-scroll:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.leaderboard-footer { border-top: 1px solid var(--line); background: var(--paper); padding-top: 8px; }
.leaderboard-modal #leaderboard-status { margin: 0 0 8px; min-height: 30px; font-size: 11px; line-height: 15px; text-align: center; }
.leaderboard-pagination { display: flex; justify-content: space-between; gap: 16px; }
.leaderboard-pagination .secondary-button { flex: 1; min-width: 0; margin: 0; min-height: 44px; font-size: 12px; }
.leaderboard-pagination button:disabled { opacity: .4; cursor: default; }
.leaderboard-pagination button:not(:disabled):hover { background: #f6e3c9; }
@media (max-height: 600px) { .modal.leaderboard-modal { padding: 22px 20px 16px; } .leaderboard-modal h2 { margin: 10px 0 12px; } }

/* Presence shares the existing footer row without reducing board capacity. */
.footer-note { align-items: center; gap: 8px; }
#progress-label { min-width: 0; }
.online-presence { margin-left: auto; }
.online-presence { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; white-space: nowrap; letter-spacing: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.online-presence::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #b6a48c; flex-shrink: 0; }
.online-presence[data-status="online"]::before { background: #618451; }
.online-presence[data-status="offline"] { opacity: .65; }
