:root {
  color-scheme: light;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  --ink: #23384a;
  --cream: #fff5d8;
  --paper: #fffaf0;
  --red: #d9684f;
  --blue: #68aeb7;
  --mustard: #e7b44b;
  --green: #779b6a;
  --plum: #855f78;
  background: #f3c879;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #f3c879; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 5%, rgba(255,255,255,.72), transparent 22rem),
    radial-gradient(circle at 88% 12%, rgba(104,174,183,.4), transparent 25rem),
    linear-gradient(150deg, #f7dda3, #ec9e73 58%, #6f9f9c);
}
button, a { font: inherit; }
button { color: inherit; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
.masthead { display: flex; justify-content: space-between; align-items: center; width: min(94vw, 1180px); min-height: 64px; margin: auto; }
.masthead a { color: var(--ink); font-weight: 900; text-decoration: none; }
.masthead button, .reset { border: 2px solid var(--ink); border-radius: 999px; padding: .58rem .95rem; background: rgba(255,250,240,.88); box-shadow: 3px 3px 0 var(--ink); font-weight: 900; cursor: pointer; }
main { width: min(94vw, 1180px); margin: auto; padding-bottom: 3rem; }
.intro { padding: clamp(1rem, 3vw, 2rem) 0 1.35rem; text-align: center; }
.eyebrow, .manual-kicker { margin: 0 0 .5rem; color: #6f4d45; font: 900 .72rem/1 ui-monospace, monospace; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(3rem, 8vw, 6.5rem); line-height: .86; letter-spacing: -.07em; text-shadow: 5px 5px 0 rgba(255,255,255,.55); }
h1 span { display: block; color: var(--cream); -webkit-text-stroke: 2px var(--ink); text-shadow: 6px 6px 0 var(--red); }
.intro > p:last-child { margin: 1.15rem 0 0; font-size: clamp(1rem, 2vw, 1.25rem); font-weight: 900; }
.game-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(280px, 1fr); gap: 1.35rem; align-items: start; }
.game-card, .manual { position: relative; border: 3px solid var(--ink); border-radius: 28px; overflow: hidden; background: var(--paper); box-shadow: 10px 10px 0 rgba(35,56,74,.24); }
.hud { display: grid; grid-template-columns: 1.35fr .8fr .72fr .85fr; border-bottom: 3px solid var(--ink); background: #fffdf6; }
.hud div { min-width: 0; padding: .65rem .45rem; text-align: center; border-right: 2px dashed rgba(35,56,74,.25); }
.hud div:last-child { border-right: 0; }
.hud span { display: block; color: #78554b; font: 900 .61rem/1 ui-monospace, monospace; letter-spacing: .09em; }
.hud strong { display: block; overflow: hidden; margin-top: .28rem; font-size: clamp(.85rem, 2vw, 1.12rem); text-overflow: ellipsis; white-space: nowrap; }
.scene-shell { position: relative; height: 200px; overflow: hidden; border-bottom: 3px solid var(--ink); background: #84c2c7; }
#scene { display: block; width: 100%; height: 100%; }
.scene-label { position: absolute; top: .7rem; left: .8rem; margin: 0; padding: .35rem .6rem; border: 2px solid var(--ink); border-radius: 999px; background: rgba(255,245,216,.9); font: 900 .67rem/1 ui-monospace, monospace; letter-spacing: .1em; }
.packing-area { display: grid; grid-template-columns: minmax(310px, 1fr) minmax(260px, .82fr); gap: 1rem; padding: 1.05rem; background: repeating-linear-gradient(135deg, #f8e8bd 0 16px, #f5dfad 16px 32px); }
.suitcase-wrap { position: relative; padding-top: 23px; }
.handle { position: absolute; top: 0; left: 50%; width: 36%; height: 38px; transform: translateX(-50%); border: 8px solid var(--ink); border-bottom: 0; border-radius: 18px 18px 0 0; background: #9f543f; }
.suitcase { position: relative; width: min(100%, 410px); aspect-ratio: 1; margin: auto; padding: 18px; overflow: hidden; border: 7px solid var(--ink); border-radius: 31px; background: #b65f47; box-shadow: inset 0 0 0 6px #df8a66, 7px 8px 0 rgba(35,56,74,.2); }
.suitcase::before, .suitcase::after { content: ""; position: absolute; z-index: 5; top: 44%; width: 18px; height: 44px; border: 4px solid var(--ink); border-radius: 6px; background: #e8b94f; }
.suitcase::before { left: -7px; }
.suitcase::after { right: -7px; }
.board { display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); width: 100%; height: 100%; padding: 6px; border: 4px solid var(--ink); border-radius: 17px; background: #e9d7ad; box-shadow: inset 0 8px 18px rgba(35,56,74,.16); touch-action: none; }
.cell { position: relative; min-width: 0; min-height: 0; border: 1px dashed rgba(35,56,74,.13); background: rgba(255,250,240,.42); }
.cell.target { background: rgba(255,250,240,.92); }
.cell.target::after { content: ""; position: absolute; inset: 19%; border-radius: 50%; background: rgba(35,56,74,.07); }
.cell.cursor { box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 7px var(--ink); }
.cell.preview-ok { background: #d9efbb; }
.cell.preview-bad { background: #f4a69b; }
.cell.filled { z-index: 1; border: 1px solid rgba(35,56,74,.35); background: var(--piece-color); box-shadow: inset 0 0 0 3px rgba(255,255,255,.28); }
.cell.filled::before { content: ""; position: absolute; inset: 14%; border: 2px solid rgba(35,56,74,.26); border-radius: 34% 44% 38% 46%; }
.cell.just-placed { animation: snap .34s cubic-bezier(.2,1.6,.35,1); }
@keyframes snap { 0% { transform: scale(1.35); filter: brightness(1.5); } 100% { transform: scale(1); } }
.strap { position: absolute; z-index: 8; pointer-events: none; background: #e6bb55; border: 4px solid var(--ink); opacity: 0; }
.strap-a { top: -12%; bottom: -12%; left: 47%; width: 10%; transform: scaleY(0); }
.strap-b { left: -12%; right: -12%; top: 47%; height: 10%; transform: scaleX(0); }
.packed-stamp { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; color: #fff9dc; font-size: clamp(1.6rem, 5vw, 3.5rem); font-weight: 1000; letter-spacing: -.03em; text-shadow: 4px 4px 0 var(--ink); opacity: 0; transform: rotate(-7deg) scale(1.8); }
.packed-stamp { pointer-events: none; }
.suitcase.is-complete .strap { opacity: 1; }
.suitcase.is-complete .strap-a { animation: strap-y .55s ease-out forwards; }
.suitcase.is-complete .strap-b { animation: strap-x .55s .28s ease-out forwards; }
.suitcase.is-complete .packed-stamp { animation: stamp .45s .68s cubic-bezier(.2,1.5,.35,1) forwards; }
@keyframes strap-y { to { transform: scaleY(1); } }
@keyframes strap-x { to { transform: scaleX(1); } }
@keyframes stamp { to { opacity: 1; transform: rotate(-7deg) scale(1); } }
.tray { min-width: 0; }
.tray-heading { display: flex; justify-content: space-between; gap: .6rem; align-items: end; padding-bottom: .7rem; border-bottom: 2px solid var(--ink); }
.tray-heading p { margin: 0; color: #78554b; font: 900 .58rem/1 ui-monospace, monospace; letter-spacing: .12em; }
.tray-heading h2 { margin: .2rem 0 0; font-size: 1.35rem; }
.tray-heading > strong { max-width: 48%; padding: .32rem .55rem; border-radius: 999px; background: var(--ink); color: #fff; font-size: .68rem; text-align: center; }
.pieces { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .55rem; min-height: 222px; padding: .8rem 0; }
.piece { display: grid; place-items: center; min-height: 66px; border: 3px solid var(--ink); border-radius: 15px; background: #fffaf0; box-shadow: 3px 3px 0 var(--ink); cursor: grab; touch-action: none; }
.piece:active { cursor: grabbing; }
.piece.is-selected { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink), 0 0 0 4px #fff, 0 0 0 7px var(--red); }
.piece.is-placed { opacity: .28; filter: grayscale(.7); pointer-events: none; }
.piece-grid { display: grid; gap: 2px; width: fit-content; }
.piece-cell { width: 15px; height: 15px; border: 1px solid var(--ink); border-radius: 4px; background: var(--piece-color); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.piece-cell.empty { visibility: hidden; }
.piece-name { margin-top: .3rem; font-size: .66rem; font-weight: 900; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.actions button { min-height: 46px; border: 2px solid var(--ink); border-radius: 13px; background: #fffaf0; box-shadow: 3px 3px 0 var(--ink); font-weight: 900; font-size: .76rem; cursor: pointer; }
.actions button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.actions #hint { grid-column: 1 / -1; background: #f5cb69; }
.actions button:disabled { opacity: .4; cursor: not-allowed; }
.message { min-height: 54px; margin: 0; padding: .9rem 1rem; border-top: 3px solid var(--ink); background: var(--ink); color: #fff9dc; text-align: center; font-weight: 900; }
.start-panel { position: absolute; z-index: 30; inset: 0; display: grid; align-content: center; justify-items: center; padding: 2rem; color: #fff9dc; text-align: center; background: linear-gradient(rgba(35,56,74,.25), rgba(35,56,74,.9)); backdrop-filter: blur(4px); }
.start-panel[hidden] { display: none; }
.panel-kicker { margin: 0; color: #f6ce67; font: 900 .7rem/1 ui-monospace, monospace; letter-spacing: .14em; }
.start-panel h2 { margin: .75rem 0; font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1.05; text-shadow: 4px 4px 0 var(--red); }
.start-panel p { max-width: 33rem; font-weight: 800; line-height: 1.7; }
.start-panel button { min-width: min(100%, 320px); border: 3px solid var(--ink); border-radius: 999px; padding: 1rem 1.35rem; background: #f4ca61; box-shadow: 5px 5px 0 var(--ink); font-size: 1.05rem; font-weight: 950; cursor: pointer; }
.start-panel .share { margin-top: .75rem; color: #fff; background: var(--red); box-shadow: 5px 5px 0 #f5cb69; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.manual { padding: clamp(1.2rem, 3vw, 1.8rem); }
.manual h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.manual ol { display: grid; gap: 1rem; margin: 1.35rem 0; padding: 0; list-style: none; }
.manual li { display: grid; grid-template-columns: 44px 1fr; gap: .75rem; align-items: start; }
.manual li > span { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 50%; background: #f5cb69; font-weight: 950; }
.manual li p, .save-note { margin: .25rem 0 0; color: #5f6768; font-size: .85rem; line-height: 1.55; }
.keyboard { padding: .8rem; border: 2px dashed var(--ink); border-radius: 14px; background: #dceee8; font-size: .8rem; font-weight: 800; }
.records { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin: 1.1rem 0; }
.records div { padding: .7rem; border: 2px solid var(--ink); border-radius: 12px; background: #fffdf6; }
.records dt { color: #78554b; font-size: .68rem; font-weight: 800; }
.records dd { margin: .16rem 0 0; font-size: 1.16rem; font-weight: 950; }
.reset { width: 100%; }
footer { width: min(94vw,1180px); margin: auto; padding: 1.5rem 0 2.5rem; text-align: center; font-weight: 850; }
body.capture { height: 100dvh; overflow: hidden; background: #23384a; }
body.capture .masthead, body.capture .intro, body.capture .manual, body.capture footer, body.capture [data-account] { display: none !important; }
body.capture main { width: 100%; height: 100dvh; padding: 0; }
body.capture .game-layout, body.capture .game-card { display: block; width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
body.capture .game-card { display: grid; grid-template-rows: auto 26vh minmax(0,1fr) auto; }
body.capture .scene-shell { height: auto; }
body.capture .packing-area { grid-template-columns: 1fr; min-height: 0; padding: 1rem 4.5rem .8rem; overflow: hidden; }
body.capture .suitcase-wrap { min-height: 0; }
body.capture .suitcase { height: min(68vw, 47vh); width: min(68vw, 47vh); }
body.capture .tray { display: grid; grid-template-columns: 1fr auto; gap: .8rem; align-items: center; }
body.capture .tray-heading { display: none; }
body.capture .pieces { grid-template-columns: repeat(4,1fr); min-height: 0; padding: .35rem 0; }
body.capture .piece { min-height: 62px; }
body.capture .actions { width: 210px; }
body.capture .actions #undo, body.capture .actions #hint { display: none; }
body.capture .actions #rotate { grid-column: 1 / -1; min-height: 60px; }
body.capture .message { min-height: 58px; font-size: 1.05rem; }
@media (max-width: 820px) {
  .masthead { min-height: 54px; }
  main { width: min(100%, 680px); padding: 0 .55rem 2rem; }
  .intro { padding: .75rem 0 1rem; }
  .game-layout { display: block; }
  .game-card { border-radius: 21px; }
  .manual { margin-top: 1rem; }
  .scene-shell { height: 160px; }
  .packing-area { grid-template-columns: minmax(250px,1fr) minmax(210px,.75fr); }
}
@media (max-width: 560px) {
  h1 { font-size: 3.2rem; }
  .intro > p:last-child { margin-top: .75rem; font-size: .9rem; }
  .hud { grid-template-columns: 1.3fr .8fr .65fr .8fr; }
  .hud div { padding: .5rem .2rem; }
  .hud span { font-size: .5rem; }
  .hud strong { font-size: .76rem; }
  .scene-shell { height: 118px; }
  .packing-area { display: block; padding: .65rem; }
  .suitcase-wrap { width: min(84vw, 335px); margin: auto; padding-top: 18px; }
  .handle { height: 30px; border-width: 6px; }
  .suitcase { border-width: 5px; border-radius: 24px; padding: 13px; }
  .board { padding: 4px; border-width: 3px; border-radius: 13px; }
  .tray { margin-top: .6rem; }
  .pieces { grid-template-columns: repeat(4,1fr); min-height: 0; gap: .35rem; padding: .55rem 0; }
  .piece { min-height: 57px; padding: .25rem; border-width: 2px; box-shadow: 2px 2px 0 var(--ink); }
  .piece-cell { width: 10px; height: 10px; border-radius: 2px; }
  .piece-name { font-size: .55rem; }
  .actions { grid-template-columns: repeat(3,1fr); gap: .35rem; }
  .actions #hint { grid-column: auto; }
  .actions button { min-height: 43px; padding: .25rem; font-size: .64rem; }
  .message { min-height: 46px; padding: .68rem .55rem; font-size: .78rem; }
  .start-panel { padding: 1.2rem; }
}
@media (max-width: 390px) {
  .scene-shell { height: 105px; }
  .suitcase-wrap { width: min(78vw, 298px); }
  .piece-name { display: none; }
  .piece { min-height: 46px; }
  .actions button { min-height: 39px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
