:root {
  color-scheme: light;
  --ink: #2c241b;
  --muted: #674e37;
  --paper: #f7ebd6;
  --card: #fff5e2;
  --line: #cdb594;
  --green: #345143;
  --red: #a63c2a;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  scroll-behavior: smooth;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background-image: repeating-linear-gradient(0deg,#57341406 0 1px,transparent 1px 4px), radial-gradient(ellipse at 25% 25%,#fff9ec 0%,transparent 68%); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #a63c2a; outline-offset: 4px; }
.wrap { width: min(1200px, calc(100% - 96px)); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); background: #f9eedbb8; }
.header-inner, nav, .brand { display: flex; align-items: center; }
.header-inner { min-height: 79px; justify-content: space-between; gap: 16px; }
.brand { font-family: Georgia, serif; font-size: clamp(1.45rem,3vw,2rem); font-weight: 900; letter-spacing: -.065em; }
.brand-mark { display: grid; place-items: center; color: #fff2da; background: var(--red); width: 32px; height: 32px; border-radius: 3px; margin-right: 10px; font: bold 25px/1 system-ui; transform: rotate(-6deg); box-shadow: 2px 2px #683629; }
.period { color: var(--red); }
nav { gap: 28px; font-size: .91rem; font-weight: 800; }
.outline, .play, .primary { display: inline-flex; align-items: center; justify-content: center; gap: 13px; border: 1px solid #685038; border-radius: 5px; min-height: 44px; padding: 8px 17px; font-weight: 800; }
.outline { background: #fbefdc; }
.outline:hover, .play:hover { background: #f2d7a9; }
.hero { display: grid; grid-template-columns: .88fr 1fr; gap: clamp(28px, 5.4vw, 80px); align-items: center; margin: 48px 0 53px; }
.kicker { display: flex; gap: 9px; align-items: center; color: var(--green); font-size: .94rem; font-weight: 900; letter-spacing: .13em; margin: 0 0 17px; }
.kicker span { width: 9px; height: 9px; border: 2px solid currentColor; transform: rotate(45deg); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 19px; font-size: clamp(2.75rem, 5.75vw, 5.2rem); font-weight: 1000; line-height: 1.08; letter-spacing: -.105em; }
.hero-description { font-size: 1rem; line-height: 1.95; font-weight: 650; color: var(--muted); margin-bottom: 22px; }
.primary { color: #fff3dc; background: var(--green); border-color: #243c32; box-shadow: 3px 4px #20372c; min-height: 50px; padding-inline: 21px; }
.primary:hover { background: #416654; }
.hero-window { position: relative; display: grid; align-items: center; isolation: isolate; min-height: 285px; aspect-ratio: 1.54; background: #bd8c52; border: 2px solid #573d26; border-radius: 8px 11px 7px 9px; box-shadow: 5px 6px #7a5435; }
.hero-window::before { content: ""; position: absolute; z-index: -1; inset: 11px; border: 1px dashed #624429a8; border-radius: 3px; background: repeating-linear-gradient(90deg,#fff3cf1a 0 1px,#55371b1c 1px 2px,transparent 3px 6px); }
.hero-window canvas { width: 100%; height: 100%; display: block; max-height: 420px; }
.tape { position: absolute; left: 34%; top: -12px; width: 30%; height: 32px; background: #f5d798d9; border: 1px solid #815a38a3; transform: rotate(-5deg); z-index: 1; clip-path: polygon(0 0,100% 0,97% 20%,100% 40%,97% 60%,100% 80%,97% 100%,0 100%,3% 76%,0 56%,3% 37%,0 17%); }
.art-caption { position: absolute; left: 24px; top: 23px; font-weight: 900; letter-spacing: .13em; font-size: .83rem; }
.stamp { position: absolute; right: 8%; top: 15%; color: #e6dbac; background: #355143; border: 3px double #e6dbac; padding: 8px 9px; transform: rotate(10deg); font: 900 clamp(.65rem,1.25vw,.95rem)/1.08 ui-monospace,monospace; text-align: center; }
.art-bars { position: absolute; bottom: 7%; right: 7%; width: 18%; height: 7%; opacity: .73; background: repeating-linear-gradient(90deg,#37271b 0 2px,transparent 2px 5px,#37271b 5px 9px,transparent 9px 11px); }
.shelf { scroll-margin-top: 18px; padding: 24px 0 44px; border-top: 2px dashed #b89c76; }
.shelf-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 20px; }
.small-label { margin-bottom: 4px; color: var(--red); font: 800 .84rem/1.2 ui-monospace,monospace; letter-spacing: .16em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.45rem); margin-bottom: 0; letter-spacing: -.06em; line-height: 1.2; }
.shelf-count { color: var(--muted); font-weight: 750; font-size: .9rem; white-space: nowrap; }
.game-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 21px; }
.card { border: 1px solid #74583c; border-radius: 8px; overflow: hidden; background: var(--card); box-shadow: 3px 4px #b08f67; display: flex; flex-direction: column; }
.card-art { position: relative; background: var(--accent); background-image: repeating-linear-gradient(90deg,#fff3cf17 0 1px,#29180c14 1px 2px,transparent 3px 6px); border-bottom: 1px solid #74583c; }
.card-art canvas { display: block; width: 100%; aspect-ratio: 2.12; }
.tag { position: absolute; top: 12px; left: 12px; padding: 4px 8px; border: 1px solid #493624; border-radius: 3px; background: #f7e5c3; font-size: .83rem; font-weight: 850; }
.card-body { padding: 15px 17px 17px; display: flex; flex-direction: column; flex: 1; }
h3 { margin-bottom: 5px; font-size: clamp(1.13rem,2.2vw,1.55rem); letter-spacing: -.055em; }
.card-body p { margin-bottom: 16px; font-size: .94rem; line-height: 1.6; color: var(--muted); }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.best { font-size: .85rem; font-weight: 800; color: var(--muted); }
.play { background: #f4ddb8; padding-inline: 12px; white-space: nowrap; }
.footer { border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; padding: 17px 0 26px; }
.footer > span { font: 900 1.22rem Georgia,serif; }
.footer small { color: var(--muted); }
.arrival { position: fixed; z-index: 4; top: 92px; left: 0; max-width: calc(100% - 12px); padding: 11px 16px; color: #fff3dc; background: var(--green); border: 1px solid #20372c; border-radius: 0 5px 5px 0; box-shadow: 3px 3px #20372c; font-size: .92rem; font-weight: 850; pointer-events: none; animation: arrive 2.1s both; }
@keyframes arrive { 0% {transform: translateX(-105%); visibility: visible;} 20%,77% {transform: translateX(0);} 100% {transform: translateX(-105%); visibility: hidden;} }
@media(prefers-reduced-motion: no-preference) {
  main { animation: reveal .4s .35s both; }
  @keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
}
dialog { width: min(580px, calc(100% - 24px)); max-height: calc(100% - 24px); color: var(--ink); background: var(--card); border: 2px solid #685038; border-radius: 9px; padding: clamp(15px,4vw,28px); box-shadow: 5px 5px #74583c; overscroll-behavior: contain; }
dialog::backdrop { background: #2c2116b0; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.close { width: 44px; padding: 0; font-size: 1.5rem; }
.game-help, .account-note { color: var(--muted); line-height: 1.6; margin-bottom: 13px; }
.account-form { display: grid; gap: 12px; }
.account-form label { display: grid; gap: 5px; font-weight: 800; }
.account-form input { min-height: 44px; padding: 8px 10px; border: 1px solid #74583c; border-radius: 4px; background: #fffaf0; }
.account-form button { justify-self: start; }
.account-mode, .account-message { margin: 12px 0 0; }
.account-message:empty, .save-message:empty { display: none; }
.account-message, .save-message { color: var(--red); font-weight: 750; }
.records { padding-left: 22px; line-height: 1.8; }
.hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 12px; font-weight: 850; font-variant-numeric: tabular-nums; margin: 10px 0; }
.board { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: clamp(5px,1.5vw,10px); }
.tile { min-width: 0; aspect-ratio: 1.15; min-height: 44px; display: grid; place-items: center; border: 1px solid #74583c; border-radius: 5px; background: repeating-linear-gradient(90deg,#d3a66d 0 3px,#cb9e65 3px 5px); box-shadow: 2px 2px #987149; font-size: clamp(1.35rem,5vw,2.25rem); font-family: system-ui,sans-serif; font-weight: 900; }
.tile.face { background: #f4d6a6; }
.tile.matched { background: #bdd2ae; }
.tile:not(:disabled):hover { filter: brightness(1.08); }
.target { font-size: 1.1rem; font-weight: 850; margin: 12px 0 0; }
.target span { font: 900 1.5rem system-ui,sans-serif; }
.stack-board { display: block; width: 100%; height: auto; max-height: 300px; border: 1px solid #74583c; border-radius: 6px; background: #d9b580; margin: 8px 0 13px; }
.result { padding: 16px; margin-top: 12px; background: #e8d0a9; border: 1px dashed #836240; border-radius: 6px; }
.result p { margin-bottom: 10px; }
body:has(dialog[open]) { overflow: hidden; }
@media(max-width: 990px) { .wrap { width: calc(100% - 56px); } .hero { gap: 30px; } .card-body { padding-inline: 12px; } }
@media(max-width: 760px) { .wrap { width: calc(100% - 36px); } .header-inner { min-height: 66px; } nav { gap: 12px; } .arrival { top: 72px; } .hero { grid-template-columns: 1fr; gap: 28px; margin: 32px 0 36px; } h1 { font-size: clamp(2.8rem, 10vw, 4.9rem); } .hero-window { min-height: 0; } .game-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; } }
@media(max-width: 480px) { .nav-games { display: none; } .game-grid { grid-template-columns: 1fr; } .card-body { padding-inline: 16px; } }
@media(prefers-reduced-motion: reduce) { :root { scroll-behavior: auto; } .arrival { animation: none; display: none; } }
