:root { color-scheme: dark; font-family: Georgia, 'Times New Roman', serif; color: #fff0ce; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.board-preview-button { margin: 0 0 20px; }
.board-screen { min-height: 100svh; padding: 20px; background: #10241699; }
.board-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 20px; max-width: 1100px; margin: auto; }
.board-toolbar h1 { font-size: 30px; }
.board-toolbar .art-button { max-width: 100%; white-space: normal; padding-left: 10px; padding-right: 10px; }
.board-toolbar p { font: 13px/1.4 system-ui, sans-serif; }
#board-canvas { height: min(72vh, 800px); min-height: 350px; width: 100%; }
#board-canvas canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#live-canvas { height: min(65vh, 720px); min-height: 350px; width: 100%; position: relative; }
#live-canvas canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.square-hint.art-surface { position: absolute; transform: translate(-50%,-50%); pointer-events: none; width: 34px; height: 34px; border: 6px solid transparent; display: grid; place-items: center; padding: 0; font: bold 14px/1 Georgia,serif; }
.room-rules-summary { max-width: 950px; margin: 16px auto; padding: 12px; font: 14px/1.7 system-ui,sans-serif; }
.room-rules-summary summary { cursor: pointer; }
.room-form { display: grid; gap: 14px; text-align: left; margin: 20px 0; }
.room-form label, .room-controls label { display: grid; gap: 7px; font: 14px/1.4 system-ui,sans-serif; }
select, input { font: 16px system-ui,sans-serif; color: #fff0ce; background: #123427; border: 1px solid #a17d41; padding: 10px; width: 100%; }
.rule-toggles { display: grid; gap: 6px; }
.rule-toggles .art-button, .room-list .art-button, #move-routes .art-button { font-size: 15px; min-height: 55px; white-space: normal; }
.room-list { display: grid; gap: 12px; margin: 20px 0; }
.room-controls { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; align-items: center; margin: 18px auto; }
.room-controls .art-button, .move-controls .art-button { font-size: 16px; min-height: 60px; }
.move-controls { max-width: 950px; margin: auto; padding: 12px; text-align: center; }
.match-actions { max-width: 950px; margin: 18px auto; padding: 12px; text-align: center; }
.match-actions .art-button { font-size: 16px; min-height: 60px; white-space: normal; }
#move-routes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
#move-routes [aria-pressed='true'] { filter: brightness(1.3); outline: 2px solid #ffea9b; }
#room-error { color: #ffcfaa; }
.board-help { text-align: center; font: 13px/1.5 system-ui, sans-serif; text-shadow: 0 2px 3px #000; }
@media (max-width: 680px) { .board-toolbar { flex-direction: column; text-align: center; } .board-toolbar p { margin: 5px 0; } .board-screen { padding: 10px; } }
body { margin: 0; min-width: 320px; min-height: 100svh; background-color: #304829; background-repeat: no-repeat; background-attachment: fixed; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.menu { min-height: 100svh; width: min(1060px, 94%); margin: auto; padding: 34px 0 20px; display: flex; flex-direction: column; align-items: center; }
.art-surface, .art-button { border: 20px solid transparent; background: #133226; background-clip: padding-box; border-image-repeat: stretch; }
.title-sign { text-align: center; min-width: 480px; padding: 10px 48px 18px; filter: drop-shadow(0 8px 3px #15271688); }
.eyebrow { font: 11px/1.5 system-ui, sans-serif; letter-spacing: .23em; text-transform: uppercase; margin: 0 0 5px; color: #dfc58d; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 49px); font-weight: bold; letter-spacing: .015em; text-shadow: 2px 3px #32220d; }
.game-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 42px; width: min(780px, 100%); margin-top: 26px; }
.game-card { position: relative; min-width: 0; padding: 15px 16px 28px; text-align: center; transition: transform .16s, filter .16s; filter: drop-shadow(0 8px 3px #15271688); }
.game-card:hover { transform: translateY(-4px); filter: brightness(1.08) drop-shadow(0 10px 4px #15271688); }
.game-card[aria-pressed='true'] { filter: drop-shadow(0 0 4px #fff2a1) drop-shadow(0 8px 4px #152716); }
.game-card h2 { margin: 0; font-size: clamp(26px, 3vw, 36px); letter-spacing: .02em; }
.variant { color: #e5ce9e; margin: 6px 0 0; font-size: 17px; }
.game-illustration { width: 100%; height: clamp(140px, 24vh, 225px); display: block; margin: 10px auto; image-rendering: auto; }
.game-detail { font-size: 14px; line-height: 1.5; max-width: 225px; min-height: 42px; margin: 0 auto; color: #dedac5; }
.selected-label { position: absolute; bottom: -15px; left: 0; right: 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #ffedae; visibility: hidden; }
[aria-pressed='true'] .selected-label { visibility: visible; }
.selection { margin: 28px 0 14px; font-size: 16px; font-weight: bold; text-shadow: 0 2px 3px #11230c, 0 0 8px #11230c; }
.actions { display: flex; gap: 16px; width: 100%; justify-content: center; }
.art-button { min-height: 73px; min-width: 0; padding: 5px 21px; font-size: clamp(15px, 1.9vw, 23px); font-weight: bold; white-space: nowrap; transition: filter .15s, transform .15s; filter: drop-shadow(0 5px 2px #15271688); }
.actions .art-button { flex: 1; max-width: 310px; }
.art-button:hover:enabled { filter: brightness(1.2) drop-shadow(0 5px 2px #15271688); transform: translateY(-2px); }
.art-button:disabled { cursor: default; filter: saturate(.5) brightness(.75); }
button:focus-visible { outline: 3px solid #ffeb9c; outline-offset: 5px; }
footer { display: flex; gap: 25px; margin-top: auto; padding-top: 23px; color: #fff2d6; font: 12px system-ui, sans-serif; text-shadow: 0 2px 4px #142310; }
.room-dialog { max-width: min(600px, 94vw); padding: 30px; text-align: center; color: #fff0ce; }
.room-dialog::backdrop { background: #07180dc9; backdrop-filter: blur(3px); }
.room-dialog h2 { font-size: 28px; }
.room-dialog p { line-height: 1.6; }
.development-note { font: 14px/1.6 system-ui, sans-serif; color: #c4cbb7; padding: 16px 0; }
#error { position: fixed; bottom: 10px; left: 10px; padding: 15px; background: #381515; color: white; }
@media (max-width: 680px) {
  .menu { padding-top: 20px; width: 94%; }
  .title-sign { min-width: 0; width: 100%; padding: 10px 12px; }
  .game-list { gap: 12px; }
  .game-card { border-width: 15px; padding: 12px 2px 20px; }
  .variant { font-size: 13px; }
  .game-card h2 { font-size: 24px; }
  .game-illustration { height: 150px; }
  .game-detail { display: none; }
  .actions { flex-direction: column; gap: 8px; align-items: center; }
  .actions .art-button { width: min(350px, 100%); max-width: none; min-height: 63px; font-size: 20px; }
  footer { margin-top: 0; }
}
.square-hint.art-surface.piece-highlight { width: 40px; height: 40px; pointer-events: none; background: transparent; }
.join-feedback, .start-countdown { margin: 12px auto; padding: 24px; width: fit-content; text-align: center; font-size: 26px; }
.join-feedback:not([hidden]) { animation: join-arrival 500ms ease-out; }
@keyframes join-arrival { from { opacity: 0; transform: translateY(12px) scale(.9); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Desktop play keeps the board and all primary actions in the same viewport. */
.turn-alert { position: relative; overflow: hidden; text-align: center; padding: 4px 12px; }
.turn-alert p { font-size: 21px; font-weight: bold; }
.turn-alert.turn-active::after { content: ''; position: absolute; top: 0; bottom: 0; left: -10%; width: 2px; background: white; box-shadow: 0 0 10px 3px #fff9; animation: turn-sweep 2.4s linear infinite; pointer-events: none; }
@keyframes turn-sweep { to { left: 110%; } }
#confirm-move.your-turn-glow { box-shadow: 0 0 13px 3px #ffe04b, inset 0 0 8px #ffe04b66; }
#confirm-move.your-turn-glow:disabled { filter: none; }
.match-clock { width: fit-content; min-width: 220px; padding: 2px 12px; text-align: center; margin: 8px 0; }
.match-clock span { font: 12px system-ui,sans-serif; color: #e5ce9e; }
.match-clock p { margin: 4px 0; font: bold 18px system-ui,sans-serif; }
#reaction-stage { position: absolute; right: 20px; top: 35%; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 12px; max-height: 60%; overflow: hidden; pointer-events: none; }
.posted-reaction { width: 130px; height: 150px; object-fit: contain; filter: drop-shadow(1px 0 0 white) drop-shadow(-1px 0 0 white) drop-shadow(0 1px 0 white) drop-shadow(0 -1px 0 white) drop-shadow(0 0 5px #fff9); }
.reaction-actions { position: relative; display: flex; justify-content: flex-end; gap: 8px; }
.reaction-control { position: relative; min-width: 0; }
.reaction-control > button { width: 100%; height: 100%; }
.reaction-picker { position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 10; display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; width: 370px; padding: 8px; }
.reaction-picker .art-button { display: flex; flex-direction: column; align-items: center; }
.reaction-picker img { width: 70px; height: 80px; object-fit: contain; }
@media (min-width: 1000px) {
  .menu { height: 100svh; min-height: 0; padding: 18px 0; gap: 10px; justify-content: center; }
  .title-sign { padding: 6px 36px; }
  .game-list { margin-top: 6px; gap: 28px; }
  .game-card { padding: 10px 16px 18px; }
  .game-illustration { height: min(21vh,210px); margin: 6px auto; }
  .selection { margin: 12px 0 0; }
  .board-preview-button { margin: 0; }
  #room-session-status:empty { display: none; }
  .menu footer { margin: 0; padding-top: 4px; }
  .menu .art-button { min-height: 56px; padding: 0 18px; font-size: 20px; }
  #live-room { height: 100svh; min-height: 0; padding: 12px; display: grid; grid-template-columns: minmax(0,1fr) 390px; grid-template-rows: auto auto minmax(0,1fr) auto; gap: 10px; position: relative; }
  #live-room .board-toolbar { grid-column: 1 / -1; width: 100%; max-width: none; padding: 2px 14px; }
  #live-room .board-toolbar h1 { font-size: 26px; }
  #live-room .board-toolbar p { display: inline-block; margin: 4px 16px 2px 0; }
  .match-clock { grid-column: 1; grid-row: 2; margin: 0; }
  #live-canvas { grid-column: 1; grid-row: 3; height: 100%; min-height: 0; }
  .room-side-panel { grid-column: 2; grid-row: 2 / 4; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
  .turn-alert { order: -2; }
  .room-side-panel .turn-alert p { font: bold 20px/1.4 Georgia,serif; }
  .reaction-actions { margin-top: auto; }
  .room-side-panel .room-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
  .room-controls label { grid-column: 1 / -1; }
  .room-side-panel .art-button { min-height: 44px; border-width: 14px; padding: 1px 6px; font-size: 14px; white-space: normal; }
  .room-side-panel .move-controls, .room-side-panel .match-actions { width: 100%; padding: 5px; margin: 0; border-width: 16px; }
  .room-side-panel .move-controls { order: -1; }
  .room-side-panel p { font: 14px/1.4 system-ui,sans-serif; margin: 7px 0; }
  .room-side-panel select, .room-side-panel input { padding: 7px; }
  #confirm-move { width: 100%; font-size: 19px; min-height: 54px; }
  #move-routes { gap: 4px; margin: 6px 0; max-height: 125px; overflow: auto; }
  .room-rules-summary { width: 100%; margin: 0; padding: 3px 8px; border-width: 14px; }
  #live-message { grid-column: 1 / -1; margin: 0; }
  #join-feedback, #start-countdown { position: absolute; z-index: 3; top: 140px; left: calc((100% - 390px) / 2); transform: translateX(-50%); pointer-events: none; }
  #start-countdown { top: 225px; }
  #board-screen { height: 100svh; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 8px; }
  #board-canvas { height: 100%; min-height: 0; position: relative; }
  .room-dialog { width: 960px; max-width: 94vw; max-height: 96svh; padding: 18px; }
  .room-dialog h2 { margin: 4px 0; }
  .room-dialog p { margin: 6px 0; }
  .room-form { grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 12px 0; }
  .room-form > p, .room-form > .rule-toggles, .room-form > button[type='submit'] { grid-column: 1 / -1; }
  .rule-toggles { grid-template-columns: 1fr 1fr 1fr; }
  .room-dialog .art-button { min-height: 48px; padding: 0 10px; font-size: 16px; border-width: 14px; }
}
@media (prefers-reduced-motion: reduce) { .turn-alert.turn-active::after { animation: none; left: 0; } }
