@font-face { font-family: Fredoka; src: url('./assets/Fredoka.ttf') format('truetype'); font-style: normal; font-weight: 300 700; font-display: swap; }
:root { --cream: #F5ECC2; --blue: #97ACC8; --rose: #B59392; --olive: #253122; --ui-top: 106px; --ui-bottom: 130px; color: var(--cream); background: var(--olive); font-family: Fredoka, -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 450; font-synthesis: none; color-scheme: dark; }
* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; }
button:not(:disabled):active { transform: translateY(1px); }
svg { width: 21px; height: 21px; flex-shrink: 0; stroke-width: 1.6; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.game { position: relative; width: 100%; height: 100%; height: 100svh; isolation: isolate; }
.board-area, #board { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#board { touch-action: none; }
.game-header { position: absolute; inset: max(28px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) auto max(32px, env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr auto; align-items: center; pointer-events: none; z-index: 3; }
.wordmark { position: relative; margin: 0; width: min(360px, calc(100vw - 100px)); aspect-ratio: 8.6; user-select: none; }
.wordmark img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 1px color-mix(in srgb, var(--olive) 65%, transparent)); opacity: 0; }
.wordmark img[data-ready='true'] { opacity: 1; }
.wordmark-fallback { position: absolute; inset: 0; display: flex; align-items: center; font: 600 29px/1 Fredoka, sans-serif; white-space: nowrap; color: var(--blue); }
.wordmark img[data-ready='true'] + .wordmark-fallback { visibility: hidden; }
.scoreboard { display: flex; align-items: center; justify-content: center; gap: 22px; }
.score-side { display: flex; align-items: center; gap: 13px; position: relative; min-height: 22px; }
.score-side strong { font-size: 12px; font-weight: 500; }
.score-side.human { color: var(--blue); }
.score-side.ai { color: var(--rose); }
.score-side[data-active='true'] strong { color: var(--cream); }
.pips { display: flex; gap: 6px; }
.pips i { width: 9px; height: 9px; display: block; border-radius: 50%; border: 1px solid currentColor; }
.pips i.done { background: currentColor; box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 12%, transparent); }
.score-divider { width: 1px; height: 13px; background: var(--cream); opacity: .2; }
.menu-anchor { justify-self: end; position: relative; pointer-events: auto; }
.icon-button { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--cream); }
.icon-button:hover, .icon-button[aria-expanded='true'] { background: color-mix(in srgb, var(--cream) 8%, transparent); }
.menu-toggle { margin-right: -9px; }
.game-menu { position: absolute; right: 0; top: 48px; width: 258px; padding: 9px; color: var(--olive); background: var(--cream); border-radius: 6px; box-shadow: 0 10px 40px color-mix(in srgb, var(--olive) 60%, transparent); max-height: calc(100svh - 120px); overflow: auto; }
.menu-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 12px; width: 100%; text-align: left; font-size: 13px; border-radius: 3px; }
.menu-item:hover:not(:disabled) { background: color-mix(in srgb, var(--olive) 8%, transparent); }
.menu-item:disabled {opacity:.4;}
.menu-item svg { width: 18px; height: 18px; }
.menu-icon { display: inline-flex; }
.menu-anchor {grid-column:2;grid-row:1;}
.solo-moves {grid-column:1;grid-row:2;font-size:13px;margin-top:12px;opacity:.8;}
.action-choice {position:fixed;z-index:8;width:232px;padding:6px;background:var(--cream);color:var(--olive);border-radius:6px;box-shadow:0 8px 28px color-mix(in srgb,var(--olive) 55%,transparent);}
.action-choice button {display:flex;align-items:center;gap:10px;text-align:left;width:100%;min-height:48px;padding:10px;font-size:13px;border-radius:3px;}
.action-choice button:hover {background:color-mix(in srgb,var(--olive) 8%,transparent);}
.choice-icon {display:inline-flex;}
.choice-icon svg {width:18px;height:18px;}
.options-dialog {width:min(360px,calc(100vw - 32px));max-height:calc(100svh - 40px);overflow:auto;padding:24px;border:1px solid var(--blue);border-radius:8px;background:var(--cream);color:var(--olive);box-shadow:0 16px 48px color-mix(in srgb,var(--olive) 50%,transparent);}
.options-dialog::backdrop {background:color-mix(in srgb,var(--olive) 75%,transparent);}
.options-dialog h2 {font-size:20px;font-weight:600;margin:0 0 22px;}
.mode-field {border:0;padding:0;margin:0 0 20px;}
.mode-field legend {font-size:13px;margin-bottom:10px;}
.mode-control {display:flex;border-bottom:1px solid var(--olive);}
.mode-control label {position:relative;flex:1;display:flex;align-items:center;justify-content:center;gap:7px;min-height:44px;font-size:13px;cursor:pointer;border-bottom:3px solid transparent;}
.mode-control label:has(input:checked) {border-bottom-color:var(--olive);background:color-mix(in srgb,var(--blue) 25%,transparent);}
.mode-control input {accent-color:var(--olive);}
.option-row {display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:66px;border-bottom:1px solid color-mix(in srgb,var(--olive) 16%,transparent);font-size:13px;}
.option-row>label {max-width:118px;line-height:1.4;}
.option-row select,.stepper input {font:inherit;color:var(--olive);background:transparent;border:1px solid color-mix(in srgb,var(--olive) 35%,transparent);border-radius:4px;height:44px;}
.option-row select {max-width:150px;padding:0 8px;}
.stepper {display:flex;align-items:center;gap:2px;}
.stepper button {display:grid;place-items:center;width:36px;height:44px;}
.stepper button:disabled {opacity:.25;}
.stepper input {width:42px;text-align:center;appearance:textfield;-moz-appearance:textfield;}
.stepper input::-webkit-inner-spin-button,.stepper input::-webkit-outer-spin-button {appearance:none;margin:0;}
.stepper input:disabled {opacity:.5;}
.dialog-actions {display:flex;justify-content:flex-end;gap:12px;padding-top:24px;}
.dialog-actions button {min-height:44px;padding:0 14px;font-size:13px;}
.primary-command {background:var(--olive);color:var(--cream);border-radius:4px;}
@media(max-width:359px){.options-dialog{padding:20px;}.option-row>label{max-width:96px;}.stepper button{width:36px;}}
@media(max-width:760px){.option-row select,.stepper input{font-size:16px;}}
.play-controls { position: absolute; left: 50%; bottom: max(25px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: start; gap: 24px; z-index: 2; }
.roster, .actions { display: flex; gap: 12px; }
.tortle-button { position: relative; display: flex; flex-direction: column; align-items: center; width: 64px; min-height: 88px; gap: 9px; border-radius: 4px; overflow: hidden; }
.piece-portrait { position: relative; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; border: 1px solid transparent; transition: background-color .18s, border-color .18s; }
.piece-portrait img { width: 100%; height: 100%; display: block; position: absolute; left: 0; top: 0; pointer-events: none; }
.tortle-button[aria-pressed='true'] .piece-portrait { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); }
.tortle-button:hover:not(:disabled) .piece-portrait { background: color-mix(in srgb, var(--blue) 15%, transparent); }
.piece-name { font-size: 12px; line-height: 16px; opacity: .76; }
.tortle-button[aria-pressed='true'] .piece-name { color: var(--blue); opacity: 1; }
.tortle-button.resting .piece-portrait img { opacity: .45; }
.tortle-button.finished .piece-portrait img { opacity: .3; }
.piece-badge { display: none; position: absolute; bottom: 1px; right: 0; background: var(--olive); color: var(--cream); border-radius: 50%; width: 20px; height: 20px; align-items: center; justify-content: center; }
.piece-badge svg { width: 13px; height: 13px; }
.tortle-button.resting .piece-badge, .tortle-button.finished .piece-badge { display: flex; }
.control-divider { margin-top: 13px; width: 1px; height: 36px; background: var(--cream); opacity: .16; }
.actions { gap: 16px; }
.action-button { display: flex; flex-direction: column; align-items: center; gap: 9px; width: 64px; min-height: 88px; border-radius: 4px; }
.action-face { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; color: var(--olive); background: var(--cream); box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--olive) 17%, transparent); transition: transform .18s; }
#flip .action-face { background: var(--blue); }
.action-icon { display: inline-flex; }
.action-icon svg { width: 25px; height: 25px; stroke-width: 1.8; }
.action-label { font-size: 12px; line-height: 16px; color: var(--cream); opacity: .9; }
.action-button:hover:not(:disabled) .action-face { transform: translateY(-2px); }
.action-button:disabled { opacity: .27; }
.endgame { position: absolute; left: 50%; bottom: max(25px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 2; }
.endgame h2 { font: 600 26px/1.1 Fredoka, sans-serif; margin: 0 0 6px; text-align: center; }
.replay { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--blue); padding: 12px 8px; }
.replay-icon { display: inline-flex; }
.render-error { position: absolute; top: 40%; left: 20px; right: 20px; text-align: center; font-size: 14px; }
body[data-phase='finished'] .play-controls { visibility: hidden; }
@media (max-width: 760px) {
  :root { --ui-top: 90px; --ui-bottom: 124px; }
  .game-header { inset: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) auto max(20px, env(safe-area-inset-left)); }
  .wordmark-fallback { font-size: 25px; }
  .scoreboard { gap: 18px; }
  .score-side { gap: 10px; }
  .score-side strong { font-size: 11px; }
  .pips { gap: 5px; }
  .pips i { width: 8px; height: 8px; }
  .menu-anchor { grid-column: 2; grid-row: 1; }
  .game-menu { top: 44px; }
  .play-controls { gap: 12px; bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px)); }
  .roster { gap: 3px; }
  .tortle-button, .action-button { width: 48px; min-height: 78px; gap: 8px; }
  .piece-portrait, .action-face { width: 48px; height: 48px; }
  .piece-name, .action-label { font-size: 11px; }
  .actions { gap: 5px; }
  .control-divider { margin-top: 9px; height: 30px; }
  .action-icon svg { width: 22px; height: 22px; }
  .endgame h2 { font-size: 25px; }
}
@media (max-width: 359px) { .play-controls { gap: 9px; } .tortle-button, .action-button { width: 44px; } .piece-portrait, .action-face { width: 42px; height: 42px; } .roster { gap: 1px; } .actions { gap: 4px; } }
@media (max-height: 600px) and (min-width: 761px) { :root { --ui-top: 80px; --ui-bottom: 110px; } .game-header { top: 18px; } .play-controls { bottom: 14px; } }
@media (orientation: landscape) and (max-height: 500px) {
  :root { --ui-top: 30px; --ui-bottom: 30px; --ui-side: 192px; }
  .game-header { inset: max(20px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) auto max(22px, env(safe-area-inset-left)); grid-template-columns: 1fr auto 1fr; }
  .wordmark { width: 154px; }
  .wordmark-fallback { font-size: 20px; white-space: normal; }
  .scoreboard { display: block; }
  .score-side { margin: 8px 0; justify-content: space-between; }
  .score-divider { display: none; }
  .score-side.ai { flex-direction: row-reverse; }
  .menu-anchor { grid-column: 3; }
  .play-controls { left: auto; right: max(22px, env(safe-area-inset-right)); bottom: max(32px, env(safe-area-inset-bottom)); transform: none; flex-direction: column; gap: 13px; }
  .roster { gap: 0; }
  .actions { align-self: center; gap: 5px; }
  .tortle-button, .action-button { width: 45px; min-height: 62px; gap: 4px; }
  .piece-portrait, .action-face { width: 42px; height: 42px; }
  .control-divider { width: 100%; height: 1px; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
