:root {
  --grass: #c5e69a;
  --ink: #34432b;
  --cream: #fffbe9;
  --display: "STKaiti", "KaiTi", "楷体", "SimSun", serif;
  --body: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--grass); }
body { margin: 0; color: var(--ink); font-family: var(--body); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid #3d7fb4; outline-offset: 5px; }
button, img { user-select: none; }
.home-screen { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 42px 20px 70px; }
h1 { font: 900 clamp(58px, 13vw, 92px)/1.2 var(--display); letter-spacing: -3px; margin: 0 0 35px; color: #34432b; text-shadow: 2px 3px 0 #f3fadf; transform: rotate(-4deg); }
.hero-portraits { position: relative; width: min(360px, 87vw); height: 220px; margin: 0 0 49px; }
.portrait-card { position: absolute; width: 36%; aspect-ratio: 1; overflow: hidden; border: 3px solid #52603b; border-radius: 12px; background: var(--cream); box-shadow: 0 7px 0 #879a5d; }
.portrait-art { width: 100%; height: 100%; position: relative; overflow: hidden; }
.portrait-art img { width: 190%; max-width: none; position: absolute; left: 0; top: var(--portrait-top); mix-blend-mode: multiply; }
.portrait-kagura { left: 0; top: 63px; transform: rotate(-14deg); --portrait-top: -41%; }
.portrait-gintoki { left: 32%; top: 16px; z-index: 2; transform: rotate(3deg); --portrait-top: -27%; }
.portrait-shinpachi { right: 0; top: 65px; transform: rotate(14deg); --portrait-top: -36%; }
.primary-button, .secondary-button { min-height: 57px; border: 3px solid #52603b; border-radius: 12px; font-size: 21px; font-weight: 800; padding: 12px 24px; background: #ffdb79; box-shadow: 0 6px 0 #879a5d; }
.primary-button:active, .secondary-button:active, .tool:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #879a5d; }
#start-button { width: min(285px, 82vw); }
.game-screen { width: min(440px, 100%); margin: 0 auto; padding: 14px 12px 32px; }
.game-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.game-controls > div { display: flex; gap: 12px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 8px; border: 2px solid #6a8650; border-radius: 50%; background: #e8f4cd; }
.icon-button svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.board { position: relative; width: 100%; aspect-ratio: 7.4 / 7.5; isolation: isolate; }
.tile { position: absolute; padding: 0; border: 2px solid #56623b; border-radius: 5px; background: var(--cream); box-shadow: 0 5px 0 #82955c, 0 6px 0 1px #56623b; overflow: hidden; }
.tile-art { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.tile-art img { position: absolute; left: 0; top: var(--portrait-top, -40%); width: 190%; height: auto; max-width: none; pointer-events: none; mix-blend-mode: multiply; }
.tile.available:hover { filter: brightness(1.045); }
.tile.available:active { transform: translateY(3px); }
.tile.blocked { filter: brightness(.72) saturate(.65); cursor: default; }
.tile.blind-covered { background: #f3efdb; filter: none; }
.tile.image-failed .tile-art::after { content: ""; position: absolute; inset: 25%; border: 3px solid #758c52; border-radius: 50%; background: var(--tile-color); }
.tile.image-failed img { display: none; }
.reserve-space { height: 56px; display: flex; justify-content: center; align-items: center; }
.reserve { display: flex; gap: 10px; }
.reserve .tile { position: relative; width: 43px; height: 43px; }
.tray-frame { padding: 11px 7px 15px; position: relative; background: #c99a66; border: 3px solid #81603e; border-radius: 7px; box-shadow: 0 5px 0 #86603a; }
.tray-frame::before, .tray-frame::after { content: ""; position: absolute; top: -8px; bottom: -10px; width: 8px; background: #a57649; border: 2px solid #81603e; border-radius: 3px; z-index: -1; }
.tray-frame::before { left: 12px; }
.tray-frame::after { right: 12px; }
.tray { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.slot { aspect-ratio: 1; position: relative; background: #a87e52; border-radius: 3px; box-shadow: inset 0 2px 2px #76533455; }
.slot .tile { position: relative; width: 100%; height: 100%; box-shadow: 0 3px 0 #82955c; animation: arrive .13s ease-out; }
.tray.danger .slot { background: #a16a49; }
.tools { display: flex; justify-content: center; gap: 28px; margin-top: 39px; }
.tool { position: relative; display: grid; place-items: center; width: 75px; height: 65px; border: 3px solid #56623b; border-radius: 12px; box-shadow: 0 6px 0 #879a5d; }
.tool svg { width: 41px; height: 41px; fill: none; stroke: #485033; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.tool-remove { background: #eed987; }
.tool-undo { background: #e9acbb; }
.tool-shuffle { background: #a3d9bd; }
.tool:disabled { filter: grayscale(.7); opacity: .46; }
.modal { width: min(350px, calc(100% - 36px)); padding: 30px 24px; border: 3px solid #52603b; border-radius: 18px; background: #edf5d1; color: var(--ink); text-align: center; box-shadow: 0 8px 0 #40512d55; }
.modal::backdrop { background: #263a235c; }
.modal h2 { font: 900 32px var(--display); margin: 0 0 28px; }
.modal button { width: 100%; font-size: 19px; margin-top: 16px; }
.secondary-button { background: #d5e8a8; }
@keyframes arrive { from { transform: translateY(-7px); } to { transform: translateY(0); } }
@media (max-width: 370px) {
  .game-screen { padding: 12px 10px 26px; }
  .game-controls { margin-bottom: 20px; }
  .hero-portraits { height: 205px; }
  .tools { gap: 25px; }
  .tool { width: 70px; height: 61px; }
}
@media (min-width: 781px) {
  .game-screen { padding-top: 26px; }
  .game-controls { margin-bottom: 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
