/* Fixed graphic and keypad; only move history scrolls. */
:root {
  color-scheme:light; --navy:#12284d; --muted:#607189; --blue:#1e66da;
  --red:#d9323d; --green:#229957; --cool:#eff4fb; --warm:#ffefb1;
  --backdrop:#f4f7fb; --edge:#dae4f0;
  font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif;
}
* {box-sizing:border-box}
html,body {margin:0;height:100%;overflow:hidden}
body {background:var(--backdrop);color:var(--navy)}
button {font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
button:disabled {cursor:not-allowed}
button:focus-visible,.history-scroller:focus-visible {outline:3px solid #7da8ee;outline-offset:1px}
[hidden] {display:none!important}
.app {
  max-width:690px;margin:0 auto;
  height:100vh;height:100dvh;
  padding:max(8px,env(safe-area-inset-top)) 11px max(7px,env(safe-area-inset-bottom));
  display:flex;flex-direction:column;gap:8px;min-height:450px;
}
.app-header {display:flex;align-items:center;padding:2px 4px 10px}
h1 {font-size:clamp(19px,5.1vw,23px);font-weight:760;letter-spacing:-.45px;line-height:1.15;margin:0}
h2 {font-size:21px;font-weight:740;letter-spacing:-.35px;margin:0}
.panel {border:1px solid var(--edge);border-radius:14px;background:#fff}
.mode-bar {flex:none;height:52px;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;padding:6px}
.mode-bar button {border:1px solid var(--edge);background:var(--cool);color:var(--navy);
  font-size:16px;font-weight:500;border-radius:8px;min-width:0}
.mode-bar button.active {background:#2b67d7;color:white;border-color:#83a8ed}
.upper {flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:8px;overflow:clip}
.history-panel {flex:1 1 0;min-height:0;display:flex;flex-direction:column;padding:9px 8px 7px;overflow:hidden}
.history-panel h2 {padding:0 4px 8px;flex:none}
.history-scroller {flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.history-table {min-width:100%;width:max-content}
.history-grid-row {display:grid;align-items:center;gap:3px;padding:5px 5px;min-height:38px;width:max-content;min-width:100%}
.history-grid-row.heading {min-height:42px;background:white}
.smallheading {font-size:11px;color:var(--muted);font-weight:750}
.history-range {color:var(--muted);font-size:11px;font-weight:750;white-space:nowrap;padding:2px 0}
.history-range.repeating-heading {background:#fff0b0}
.move-number {font-size:13px;color:var(--muted)}
.move-player {font-weight:750;font-size:19px}
.move-player.x {color:var(--blue)}
.move-player.o {color:var(--red)}
.coord {display:flex;align-items:center;justify-content:center;background:#edf3fb;color:var(--navy);
  height:31px;font-family:ui-monospace,Menlo,monospace;font-size:14px}
.coord.repeating {background:var(--warm)}
.ellipsis {color:#7c8aa0;font-weight:bold;padding-left:3px}
.history-grid-row.winning {background:#e5f9ed;border-radius:7px}
.history-grid-row.threat-x {background:#e2f0ff;border-radius:7px}
.history-grid-row.threat-o {background:#ffe4e7;border-radius:7px}
.empty-history {padding:19px 6px;color:var(--muted);font-size:13px}
.history-status {padding:12px 7px 10px;min-width:max-content}
.turn-status {font-size:14px;color:var(--blue);font-weight:750}
.turn-status.x {color:var(--blue)}
.turn-status.o {color:var(--red)}
.turn-status.win {color:var(--green)}
.threat-status {font-size:12px;color:#9a631f;margin-top:5px}
.error-status {font-size:12px;color:#bf2337;margin-top:5px}
.threat-status:empty,.error-status:empty {display:none}
.guide-and-radial {flex:none;height:184px;padding:6px;display:grid;
  grid-template-columns:minmax(0,52fr) minmax(0,48fr);gap:6px;overflow:hidden}
.guide-area {background:#ecf4ff;border-radius:9px;overflow:clip;
  padding:8px 9px;min-width:0;min-height:0}
.guide-heading {font-size:13px;font-weight:750;line-height:1.28;margin-bottom:4px}
.guide-body {font-size:12px;line-height:1.35;white-space:pre-line;overflow-wrap:break-word}
.radial-area {display:flex;justify-content:center;align-items:center;min-width:0;overflow:hidden}
#gameSvg {display:block;width:100%;height:100%;max-width:180px;max-height:172px}
.bottom-dock {flex:none}
.entry-panel {padding:8px 11px 10px}
.field-grid {display:grid;grid-template-columns:1fr 1fr;gap:8px}
.field-grid.finite {grid-template-columns:1fr}
.field-heading {display:flex;align-items:center;justify-content:space-between;min-height:19px;gap:7px}
.field-heading label,.coordinate-count {font-size:11px;color:var(--muted);font-weight:600}
.field-heading label {white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.coordinate-count {flex:none}
.digit-field {display:block;width:100%;min-width:0;height:42px;border:2px solid var(--edge);
  border-radius:8px;background:var(--cool);color:var(--navy);font-size:16px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:1px}
.digit-field.selected {border-color:var(--blue)}
.digit-field.repeating {background:var(--warm)}
.keypad {display:grid;grid-template-columns:minmax(0,1.35fr) repeat(3,minmax(0,1fr)) minmax(0,1.35fr);gap:6px;margin-top:8px}
.keypad button {height:43px;border-radius:9px;border:1px solid var(--edge);
  background:var(--cool);font-size:19px;color:var(--navy)}
.keypad #deleteBtn {font-size:15px}
.keypad .go-button {display:block;width:100%;min-width:0;border:none;
  background:#2c67d9;color:white;font-weight:750;font-size:20px}
.keypad .go-button:disabled {background:#c2cddd;color:#607189}
@media(max-height:730px){
  .app {gap:6px}
  .mode-bar {height:46px}
  .guide-and-radial {height:172px}
  .entry-panel {padding:6px 9px 8px}
  .keypad {margin-top:6px}
}
@media(max-width:375px) {
  .app {padding-left:7px;padding-right:7px}
  h1 {font-size:19px}
  .field-heading label {font-size:10px}
  .mode-bar button {font-size:15px}
  .keypad {gap:4px}
  .keypad #deleteBtn {font-size:13px}
  .guide-and-radial .guide-body {font-size:11px;line-height:1.25}
  .guide-and-radial .guide-heading {font-size:12px}
}
@media(max-height:560px){
  .app {min-height:0;gap:4px}
  .mode-bar {height:38px;padding:3px}
  .upper {gap:4px}
  .history-panel {padding:4px 6px}
  .history-panel h2 {font-size:16px;padding-bottom:3px}
  .guide-and-radial {height:clamp(96px,27dvh,150px)}
  .guide-and-radial .guide-area {padding:4px 6px}
  .guide-and-radial .guide-heading {font-size:11px;margin-bottom:2px}
  .guide-and-radial .guide-body {font-size:10px;line-height:1.2}
  .entry-panel {padding:4px 8px}
  .field-heading {min-height:15px}
  .digit-field {height:32px}
  .keypad {margin-top:4px}
  .keypad button {height:31px}
}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* Keep the reserved 4D visualization area plain. */
#reserved4DGuideSpace {background:transparent}
