:root { color: #18254b; background: #f8f1ff; font-family: ui-rounded, system-ui, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(circle at 85% 4%, #dfd2ff 0 11rem, transparent 11rem), #f8f1ff; }
button, a { font: inherit; }
button { min-height: 44px; padding: .55rem .75rem; border: 3px solid #18254b; border-radius: 14px; color: #18254b; background: #fff; font-weight: 800; cursor: pointer; }
button[aria-disabled="true"], button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, a:focus-visible { outline: 4px solid #f06f58; outline-offset: 3px; }
.primary { min-height: 48px; background: #ffd45d; }
.game-bar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: .5rem max(1rem, calc((100vw - 1100px) / 2)); color: #fff; background: #18254b; }
.game-bar a { min-height: 44px; display: inline-flex; align-items: center; color: #fff; font-weight: 800; }
.game-bar p { margin: 0; font-size: .8rem; letter-spacing: .08em; }
main { max-width: 1100px; margin: auto; padding: clamp(.7rem, 3vw, 2rem); }
.card { border: 3px solid #18254b; border-radius: 22px; background: #fff; box-shadow: 6px 7px 0 #18254b; }
.welcome { max-width: 840px; min-height: 235px; display: grid; grid-template-columns: 1.25fr .75fr; gap: 1rem; margin: clamp(.5rem, 4vh, 2rem) auto; padding: clamp(1rem, 4vw, 2rem); }
h1 { margin: .2rem 0; font-size: clamp(2rem, 6vw, 3.7rem); }
.eyebrow { margin: 0; color: #6742b5; font-size: .8rem; font-weight: 900; letter-spacing: .08em; }
.welcome-actions, .actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.opening-board { display: grid; align-content: center; gap: .6rem; }
.opening-board b, .bowl { padding: .7rem; border: 3px solid #18254b; border-radius: 16px; background: #dcefff; }
.opening-board b:last-child, .bowl.hill { background: #efe0c8; }
.opening-board span { display: block; margin-top: .35rem; letter-spacing: .25rem; }
.round-head { margin-bottom: .7rem; }
.round-head h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
#status { min-height: 1.35rem; margin: .25rem 0; font-weight: 800; }
.rule-strip { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; margin-bottom: .8rem; padding: .6rem .8rem; border: 3px solid #18254b; border-radius: 16px; background: #fff0c3; }
.rule-strip span { flex: 1; }
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: 1rem; }
.board-card, .controls, .ending { padding: 1rem; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.bowl { min-height: 220px; display: flex; flex-direction: column; justify-content: space-between; }
.bowl h2 { margin: 0; font-size: 1.2rem; }
.pebbles { min-height: 115px; display: flex; flex-wrap: wrap; align-content: end; gap: .35rem; }
.pebble { width: 34px; height: 28px; display: block; border: 3px solid #18254b; border-radius: 50% 45% 48% 42%; background: #a790d9; }
.hill .pebble { background: #e39f72; }
.count { font-weight: 900; }
.preview, .result, #undo-note { min-height: 2.2rem; padding: .6rem; border-radius: 12px; background: #fff3ca; font-weight: 700; }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.moves button { min-height: 48px; }
.moves button.selected { background: #dff4e2; box-shadow: inset 0 0 0 3px #17834b; }
.controls h2 { margin-top: 0; }
.controls #commit { width: 100%; margin-top: .65rem; }
.ending { max-width: 760px; margin: 1rem auto; text-align: center; }
dialog { max-width: min(780px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); border: 3px solid #18254b; border-radius: 22px; color: #18254b; background: #fff; }
dialog::backdrop { background: #18254b99; }
dialog section { padding: 1rem; overflow: auto; }
dialog header { display: flex; align-items: start; justify-content: space-between; gap: .5rem; }
dialog h2 { margin: 0; }
dialog a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 1rem; color: #18254b; font-weight: 800; }
.help-diagrams { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .8rem; }
.help-diagrams figure { margin: 0; padding: .7rem; border: 2px solid #18254b; border-radius: 14px; }
.help-diagrams figcaption { font-weight: 900; }
.diagram-piles { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .4rem; font-size: .82rem; }
.diagram-piles b { padding: .45rem; border-radius: 10px; background: #dcefff; }
.diagram-piles .removed { background: #ffe3dc; text-decoration: line-through; }
.reason-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.reason-table td, .reason-table th { padding: .35rem; border: 1px solid #18254b; text-align: left; }
@media (max-width: 650px) {
  .welcome, .layout { grid-template-columns: 1fr; }
  main { padding: .45rem; }
  .welcome { margin: .4rem auto; }
  .round-head { margin-bottom: .3rem; }
  .round-head h1 { margin: .1rem 0; font-size: 1.45rem; }
  #status { min-height: 0; margin: .15rem 0; font-size: .82rem; }
  .rule-strip { gap: .35rem; margin-bottom: .4rem; padding: .4rem .5rem; font-size: .78rem; }
  .board { gap: .45rem; }
  .board-card { padding: .5rem; }
  .bowl { min-height: 120px; padding: .4rem; }
  .bowl h2 { font-size: 1rem; }
  .pebbles { min-height: 48px; }
  .pebble { width: 27px; height: 23px; }
  .preview, .result, #undo-note { min-height: 0; margin: .3rem 0; padding: .35rem; font-size: .78rem; }
  .controls { padding: .55rem; }
  .controls h2 { margin: 0 0 .35rem; font-size: 1rem; }
  .controls #commit { margin-top: .45rem; }
  .actions { gap: .35rem; margin-top: .5rem; }
  .help-diagrams { grid-template-columns: 1fr; }
}
@media (max-height: 360px) and (orientation: landscape) {
  .game-bar { min-height: 42px; padding-top: .2rem; padding-bottom: .2rem; }
  main { padding: .3rem .65rem; }
  .welcome { min-height: 0; grid-template-columns: 1fr 1fr; margin: .2rem auto; padding: .5rem .75rem; }
  .welcome p { margin: .2rem 0; font-size: .82rem; }
  .welcome h1 { font-size: 1.55rem; }
  .welcome-actions { margin-top: .35rem; }
  .opening-board { grid-template-columns: 1fr 1fr; }
  .opening-board b { padding: .35rem; }
  .round-head { margin-bottom: .2rem; }
  .round-head h1 { font-size: 1.2rem; }
  .rule-strip { margin-bottom: .35rem; padding: .3rem .5rem; font-size: .78rem; }
  .layout { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .board-card, .controls { padding: .5rem; }
  .bowl { min-height: 118px; }
  .pebbles { min-height: 48px; }
  .pebble { width: 20px; height: 17px; border-width: 2px; }
  .preview, .result, #undo-note { min-height: 0; margin: .3rem 0; padding: .35rem; font-size: .75rem; }
  .moves { gap: .3rem; }
  .moves button, .actions button { padding: .35rem .45rem; font-size: .76rem; }
  .actions button { min-height: 44px; }
  .moves button, .actions .primary { min-height: 48px; }
}
@media (min-width: 600px) and (max-height: 430px) and (orientation: landscape) {
  .ending { padding: .6rem; }
  #ending-title { font-size: 1.15rem; margin-block: .3rem; }
  #ending-support { font-size: .8rem; margin-block: .3rem; }
  .ending .actions { justify-content: center; margin-top: .45rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
