.crates-game {
  --cr-ink: #263e42;
  --cr-muted: #536b68;
  --cr-paper: #f7f1df;
  --cr-floor: #d9cba5;
  --cr-teal: #3d716d;
  color: var(--cr-ink);
  font: 500 1rem/1.4 system-ui, sans-serif;
}
.crates-game * { box-sizing: border-box; }
.cr-shell { max-width: 1180px; margin: 0 auto; padding: clamp(12px, 2vw, 24px); border: 1px solid #d5c9a8; border-radius: 18px; background: var(--cr-paper); }
.cr-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.cr-heading h2 { margin: 0; font: 700 clamp(1.5rem, 3vw, 2.25rem)/1.1 Georgia, serif; }
.cr-kicker { margin: 0 0 .3rem; color: var(--cr-teal); font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
.cr-memory { max-width: 18rem; margin: 0; color: var(--cr-muted); font-size: .84rem; text-align: right; }
.cr-instructions { max-width: 80ch; margin: .8rem 0 1rem; color: var(--cr-muted); }
.cr-toolbar, .cr-readouts, .cr-actions, .cr-dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.cr-toolbar { justify-content: space-between; }
.cr-readouts { color: var(--cr-muted); font-size: .9rem; }
.cr-readouts > span { padding: .35rem .6rem; border-radius: 999px; background: #eae9db; }
.crates-game button, .crates-game select { min-height: 42px; padding: .45rem .8rem; border: 1px solid #a9b7ac; border-radius: 9px; background: #fff; color: var(--cr-ink); font: inherit; cursor: pointer; }
.crates-game button:hover:not(:disabled), .crates-game select:hover { border-color: var(--cr-teal); background: #eef4e8; }
.crates-game button:focus-visible, .crates-game select:focus-visible, .crates-game:focus-visible { outline: 3px solid #a95837; outline-offset: 2px; }
.crates-game button:disabled { opacity: .5; cursor: not-allowed; }
.cr-rewards { margin: .6rem 0 1rem; color: var(--cr-muted); font-size: .85rem; }
.cr-play-area { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(190px, 230px); align-items: center; gap: clamp(1rem, 3vw, 2rem); }
.cr-board-frame { width: max-content; max-width: 100%; margin: 0 auto; padding: 8px; overflow: auto; border: 4px solid #594737; border-radius: 13px; background: #594737; box-shadow: 0 5px 0 #392f28; }
.cr-board { --cr-cell: clamp(40px, min(8vh, 6vw), 74px); display: grid; grid-template-columns: repeat(var(--cr-width), var(--cr-cell)); grid-template-rows: repeat(var(--cr-height), var(--cr-cell)); width: max-content; border: 2px solid #594737; background: var(--cr-floor); }
.cr-cell { position: relative; display: grid; place-items: center; min-width: 0 !important; min-height: 0 !important; width: var(--cr-cell); height: var(--cr-cell); padding: 0 !important; border: 1px solid #bcae88 !important; border-radius: 0 !important; background: var(--cr-floor) !important; color: var(--cr-ink) !important; font: 700 clamp(1.2rem, 2.5vw, 2rem)/1 system-ui, sans-serif !important; }
.cr-cell.is-floor { cursor: pointer; }
.cr-cell.is-floor:hover:not(:disabled) { background: #ece1c5 !important; }
.cr-cell.is-wall { border-color: #39494a !important; background: repeating-linear-gradient(135deg, #51615e 0 8px, #67736b 8px 13px) !important; color: #e9dfc7 !important; }
.cr-wall-mark { opacity: .55; }
.cr-cell.is-goal { box-shadow: inset 0 0 0 4px #b7674380; }
.cr-cell.has-crate:not(.crate-on-goal) { background: #bf8f51 !important; }
.cr-cell.crate-on-goal { background: #d6c796 !important; }
.cr-goal-mark, .cr-crate-mark, .cr-player-mark { position: absolute; display: grid; place-items: center; inset: 0; pointer-events: none; }
.cr-goal-mark { z-index: 0; color: #9b5035; font-size: .67em; text-shadow: 0 1px #fff8e4; }
.cr-crate-mark { z-index: 1; inset: 12%; border: 3px solid #5b432d; border-radius: 4px; background: repeating-linear-gradient(0deg, #bd8b4a 0 7px, #d3ab68 7px 11px); color: #3e463f; box-shadow: inset 4px 0 #fff3cb77, 0 2px 0 #755637; font-size: .72em; }
.cr-cell.crate-on-goal .cr-crate-mark { border-color: #3f655c; background: repeating-linear-gradient(45deg, #6c9b82 0 7px, #94b99a 7px 11px); color: #fff; }
.cr-player-mark { z-index: 2; font-size: .78em; filter: drop-shadow(0 1px 1px #453e2e); }
.cr-cell:focus-visible { z-index: 3; outline: 4px solid #b44f31 !important; outline-offset: -4px; }
.cr-cell.is-deadlocked:not(.crate-on-goal) .cr-crate-mark { border-style: dashed; background-color: #b5624b; }
.cr-side { display: grid; justify-items: center; gap: 1rem; padding: 1rem; border: 1px solid #d8d0b9; border-radius: 14px; background: #f0ecdE; }
.cr-pad { display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(2, 48px); gap: 5px; }
.cr-pad button { min-width: 50px; min-height: 46px; padding: 0; border-color: #617a70; background: #fffdf6; font-size: 1.4rem; font-weight: 800; }
.cr-pad button[data-direction="up"] { grid-column: 2; grid-row: 1; }
.cr-pad button[data-direction="left"] { grid-column: 1; grid-row: 2; }
.cr-pad button[data-direction="down"] { grid-column: 2; grid-row: 2; }
.cr-pad button[data-direction="right"] { grid-column: 3; grid-row: 2; }
.cr-legend { display: grid; gap: .35rem; margin: 0; color: var(--cr-muted); font-size: .84rem; }
.cr-legend-item { display: flex; align-items: center; gap: .5rem; }
.cr-legend-item i { display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 3px; font-style: normal; font-weight: 900; }
.cr-legend-wall { background: repeating-linear-gradient(135deg, #51615e 0 5px, #67736b 5px 8px); color: white; }
.cr-legend-goal { background: #e8d7b4; color: #9b5035; }
.cr-legend-crate { border: 2px solid #5b432d; background: #c99a58; color: #3c433d; }
.cr-legend-filled { border: 2px solid #3f655c; background: #83aa8d; color: white; }
.cr-goal-note { margin: 0; color: var(--cr-muted); font-size: .82rem; }
.cr-crate-mark:empty { display: none; }
.cr-board { --cr-cell: clamp(32px, 5.7vh, 58px); }
.cr-status { min-height: 1.5em; margin: .9rem 0 .45rem; font-weight: 750; color: var(--cr-ink); }
.cr-status.is-success { color: #216548; }
.cr-status.is-paused { color: #865920; }
.cr-help { margin: 0; color: var(--cr-muted); font-size: .86rem; }
.cr-dialog { width: min(92vw, 460px); padding: 1.25rem; border: 1px solid #a9b7ac; border-radius: 16px; color: var(--cr-ink); background: var(--cr-paper); box-shadow: 0 15px 55px #1d302e55; }
.cr-dialog::backdrop { background: #172b2a88; }
.cr-dialog h3 { margin: 0 0 .4rem; font: 700 1.45rem Georgia, serif; }
.cr-dialog p { color: var(--cr-muted); }
.cr-dialog label { display: grid; gap: .25rem; margin: .8rem 0; font-weight: 700; }
.cr-dialog-actions { justify-content: flex-end; margin-top: 1rem; }
@media (max-width: 820px) {
  .cr-heading { align-items: flex-start; }
  .cr-play-area { grid-template-columns: 1fr; }
  .cr-side { grid-template-columns: auto 1fr; justify-content: center; align-items: center; }
}
@media (max-width: 600px) {
  .cr-heading { display: block; }
  .cr-memory { max-width: none; margin-top: .45rem; text-align: left; }
  .cr-toolbar { align-items: flex-start; }
  .cr-actions { width: 100%; }
  .cr-actions button { flex: 1; }
  .cr-play-area { min-width: 0; container-type: inline-size; }
  .cr-board { --cr-cell: min(36px, calc((100cqi - 28px) / var(--cr-width))); }
  .cr-side { grid-template-columns: 1fr; }
}
@media (max-height: 760px) and (min-width: 821px) {
  .cr-shell { padding-block: 10px; }
  .cr-heading { display: none; }
  .cr-instructions { max-width: none; font-size: .88rem; }
  .cr-instructions { margin-block: .45rem .7rem; }
  .cr-board { --cr-cell: clamp(32px, 5.7vh, 48px); }
  .cr-rewards { margin-block: .45rem; }
  .cr-play-area { gap: 1rem; }
  .cr-side { padding: .7rem; }
}
@media (prefers-reduced-motion: reduce) { .crates-game *, .crates-game *::before, .crates-game *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
