:root {
  color-scheme: light; font-family: system-ui, "Yu Gothic", sans-serif;
  background: #f5f1e7; color: #253830;
  --green: #215842; --line: #dedbd0; --paper: #fffdf6;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
button { font: inherit; cursor: pointer; color: inherit; min-height: 44px; border-radius: 10px; }
button:focus-visible, a:focus-visible { outline: 3px solid #d6953d; outline-offset: 3px; }
button:disabled { cursor: default; opacity: .58; }
[hidden] { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 840px; margin: auto; padding: 18px 20px; }
.brand { color: inherit; text-decoration: none; font-weight: 900; font-size: clamp(.84rem, 3.3vw, 1.15rem); }
.brand span { display: inline-grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; background: var(--green); color: white; margin-right: 5px; }
.book-button, .secondary, .choice { background: var(--paper); border: 1px solid var(--line); }
.book-button { padding: 0 10px; font-size: .8rem; white-space: nowrap; }
.book-button strong { margin-left: 4px; color: var(--green); }
main { width: min(800px, calc(100% - 32px)); margin: 0 auto; }
.board { min-height: 190px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 15px; color: #fff9df; background: #244b3d; border: 6px solid #9d7255; border-radius: 14px; padding: clamp(15px, 4vw, 25px); box-shadow: inset 0 0 30px #132f27, 0 4px #e1d7c5; }
.kicker { margin: 0; color: #f3cc86; font-size: .78rem; font-weight: 700; letter-spacing: .12em; }
h1 { margin: 5px 0; font-size: clamp(1.55rem, 6vw, 2.35rem); line-height: 1.25; }
#clue { margin: 8px 0 0; font-size: .9rem; }
.hint { background: transparent; border: 0; color: #f3cc86; padding: 0 4px; text-decoration: underline; }
.reference { width: min(150px, 100%); aspect-ratio: 3/2; border-radius: 5px; overflow: hidden; }
.flag-image { width: 100%; height: 100%; object-fit: fill; }
.desk { margin-top: 20px; padding: clamp(14px, 4vw, 25px); background: var(--paper); border: 1px solid var(--line); border-radius: 17px; }
.section-head, .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
h2 { margin: 0; font-size: 1.05rem; }
.quiet { background: transparent; border: 0; padding: 0 9px; color: var(--green); font-weight: 700; }
.workspace { display: grid; place-items: center; padding: 13px; border-radius: 11px; background-color: #e9eee4; background-image: radial-gradient(#b9c9ba 1px, transparent 1px); background-size: 12px 12px; }
.flag { width: min(100%, 300px); aspect-ratio: 3/2; position: relative; background: #dddcd1; outline: 1px solid #243b3560; overflow: hidden; border-radius: 3px; }
.flag > svg { display: block; width: 100%; height: 100%; }
.instruction { font-size: .84rem; color: #52675c; margin: 12px 0; }
.parts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.parts-label { min-width: 44px; font-size: .82rem; font-weight: 700; }
.choice { padding: 0 10px; font-size: .86rem; display: inline-flex; align-items: center; gap: 5px; }
.choice[aria-pressed="true"] { background: #e3efe5; border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.swatch { width: 16px; height: 16px; border: 1px solid #0004; border-radius: 50%; }
.actions { display: flex; justify-content: space-between; gap: 10px; }
.actions button { padding: 0 14px; font-size: .9rem; font-weight: 700; }
.primary { background: var(--green); color: white; border: 1px solid var(--green); }
.primary span { padding-left: 8px; }
#status { min-height: 1.4em; margin: 10px 0; font-size: .87rem; font-weight: 700; }
footer { text-align: center; padding: 17px; color: #566960; font-size: .74rem; }
footer a { color: inherit; }
dialog { color: inherit; width: min(440px, calc(100% - 32px)); max-height: 82dvh; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); padding: 20px; }
dialog::backdrop { background: #152b24a0; }
.flag.square { width: min(100%, 200px); aspect-ratio: 1; }
.flag.wide { aspect-ratio: 2; }
.flag.band-flag { aspect-ratio: 5/3; }
.reference .flag-image { object-fit: contain; }
.emblem-choice { width: 48px; height: 48px; padding: 3px; background: #52675c; }
.emblem-choice[aria-pressed="true"] { background: #325848; outline: 2px solid #b16a14; outline-offset: 1px; }
.emblem-choice svg { width: 100%; height: 100%; }
.emblem-choice[aria-label="塗りつぶしの星"],
.emblem-choice[aria-label="六芒星"],
.emblem-choice[aria-label="五芒星"],
.emblem-choice[aria-label="輪郭だけの星"],
.emblem-choice[aria-label="ひし形"] { background: #aebcaf; }
.pattern-choice { width: 59px; height: 48px; padding: 4px; }
.pattern-choice img, .flag > .flag-image { object-fit: contain; }
#book { width: min(540px, calc(100% - 24px)); padding: clamp(13px, 4vw, 25px); background: #fbf5e5; }
#book-count { margin: 0 0 12px; color: #5e5344; font-size: .83rem; }
.book-spread {
  padding: 7px 12px 11px 22px;
  border-radius: 12px 9px 9px 12px;
  background: linear-gradient(90deg, #493024 0, #7a4b34 14px, #87523a 22px, #633e2b 100%);
  perspective: 850px;
  touch-action: pan-y;
}
.book-page {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 11px;
  min-height: clamp(210px, 45vh, 310px);
  padding: 20px 16px;
  border-radius: 3px 8px 7px 2px;
  background: linear-gradient(90deg, #ddc9a7, #fffaf0 10%, #fdf4df 98%, #e8d6b8);
  box-shadow: 0 3px #eadbc0, 0 5px #c6ab83, 0 7px #f1dfbc;
  transform-origin: left center;
}
.book-page h3 { margin: 0; overflow-wrap: anywhere; text-align: center; font-size: clamp(1rem, 4.5vw, 1.42rem); }
.book-number { margin: 0; color: #75543c; font: 700 1rem Georgia, serif; letter-spacing: .17em; }
.book-plate { display: grid; place-items: center; width: min(100%, 220px); height: clamp(86px, 22vh, 135px); }
.book-plate img { object-fit: contain; }
.book-plate.uncollected {
  border: 1px dashed #a99071;
  border-radius: 6px;
  color: #6d5c48;
  font-size: .85rem;
  background: #eadcc64d;
}
.book-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; margin-top: 14px; }
.book-nav button { padding-inline: 8px; white-space: nowrap; }
.book-nav button[aria-disabled="true"] { opacity: .47; cursor: default; }
.book-nav select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: inherit; font: inherit; }
.book-page.turn-forward { animation: book-forward .25s ease-out; }
.book-page.turn-back { animation: book-back .25s ease-out; }
@keyframes book-forward { from { transform: rotateY(-32deg); opacity: .62; } }
@keyframes book-back { from { transform: rotateY(25deg); opacity: .62; } }
@media (prefers-reduced-motion: reduce) {
  .book-page.turn-forward, .book-page.turn-back { animation: none; }
}
.motif-choice.emblem-choice {
  display: grid;
  place-items: center;
  width: clamp(42px, 12vw, 64px);
  height: 58px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #fffdf6;
}
.motif-choice.emblem-choice[aria-pressed="true"] { background: #e3efe5; border-color: var(--green); }
.motif-choice, .motif-placement { container-type: size; }
.motif-placement {
  position: absolute;
  display: grid;
  place-items: center;
}
.motif-crop {
  position: relative;
  display: block;
  width: min(100cqw, calc(100cqh * var(--crop-ratio)));
  aspect-ratio: var(--crop-ratio);
  overflow: hidden;
}
.motif-crop img { position: absolute; display: block; max-width: none; }
.motif-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.background-art, .painted-background { width: 100%; height: 100%; }
.background-art { display: block; object-fit: fill; }
.background-choice .background-art { object-fit: contain; }
.painted-background { display: flex; flex-direction: column; }
.painted-background.vertical { flex-direction: row; }
.painted-background span { flex-basis: 0; }
.expanded-choice img, .expanded-motif img { display: block; width: 100%; height: 100%; object-fit: contain; }
.motif-choice.expanded-choice {
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  background: #b9c5b8;
}
.motif-choice.expanded-choice[aria-pressed="true"] { background: #9eb49f; }
.expanded-choice img, .expanded-motif img { min-width: 0; min-height: 0; }
.badge-panel { margin-bottom: 14px; border: 1px solid #d5c5a9; border-radius: 9px; background: #fffaf0; }
.badge-panel summary { cursor: pointer; min-height: 44px; padding: 11px 12px; font-weight: 750; }
.badge-panel summary strong { float: right; color: var(--green); font-size: .83rem; }
#badge-list { display: grid; gap: 7px; margin: 0; padding: 0 10px 10px; list-style: none; }
.badge-card { --badge-ink: #59645e; --badge-fill: #edede4; display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 10px; padding: 7px; border: 1px solid #e1d7c5; border-radius: 7px; }
.badge-card.earned.red { --badge-ink: #842c30; --badge-fill: #f8ded2; }
.badge-card.earned.blue { --badge-ink: #28527d; --badge-fill: #ddebf4; }
.badge-card.earned.green { --badge-ink: #235943; --badge-fill: #dcefe0; }
.badge-medal { display: grid; width: 42px; height: 42px; place-items: center; border: 2px solid currentColor; border-radius: 50%; color: var(--badge-ink); background: var(--badge-fill); font-size: 1.3rem; line-height: 1; }
.badge-card strong { font-size: .87rem; }
.badge-card p { margin: 1px 0; font-size: .76rem; color: #52675c; }
.badge-card progress { display: block; width: 100%; height: 8px; accent-color: var(--badge-ink); }
.badge-card.earned.gold { --badge-ink: #775016; --badge-fill: #fae2a3; border-color: #c79c59; }
.badge-celebration {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
}
.celebration-card {
  --medal-light: #fff4c9;
  --medal-mid: #e8b653;
  --medal-edge: #956222;
  --medal-symbol: #533207;
  width: min(100%, 330px);
  min-height: 240px;
  padding: 28px 20px;
  display: grid;
  grid-template-rows: 110px minmax(42px, auto);
  justify-items: center;
  align-content: center;
  align-items: center;
  gap: 18px;
  border-radius: 22px;
  background: radial-gradient(ellipse at 50% 25%, #54705b, #172d24 76%);
  border: 1px solid #c6a868;
  color: #fff6db;
  box-shadow: 0 14px 55px #142a27a6;
  text-align: center;
  perspective: 450px;
}
.celebration-card.blue {
  --medal-light: #f4faff;
  --medal-mid: #b4d2df;
  --medal-edge: #54788d;
  --medal-symbol: #244b68;
}
.celebration-card.green {
  --medal-light: #fff0d4;
  --medal-mid: #d7aa75;
  --medal-edge: #92603f;
  --medal-symbol: #503318;
}
.celebration-medal {
  display: grid;
  place-items: center;
  width: 106px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--medal-edge);
  box-shadow: inset 0 0 0 3px var(--medal-light), 0 0 28px #ffd67980;
  background: linear-gradient(135deg, var(--medal-mid) 8%, var(--medal-light) 38%, var(--medal-mid) 66%, var(--medal-edge) 110%);
  color: var(--medal-symbol);
  font: 700 3.2rem/1 Georgia, serif;
  animation: medal-spin 500ms ease-out both;
}
.celebration-title { margin: 0; font-size: clamp(1.08rem, 5vw, 1.4rem); font-weight: 900; animation: medal-title 180ms ease-out both; }
@keyframes medal-spin {
  from { transform: rotateY(-360deg) scale(.72); filter: brightness(.8); }
  76% { filter: brightness(1.7); box-shadow: inset 0 0 0 3px var(--medal-light), 0 0 56px #fff2aeb0; }
  to { transform: rotateY(0) scale(1); filter: brightness(1); }
}
@keyframes medal-title {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .celebration-medal, .celebration-title { animation: none; }
}
.top-actions { display: flex; flex-wrap: wrap; gap: 6px; white-space: nowrap; }
#world-map { width: min(1000px, calc(100% - 24px)); padding: clamp(12px, 3vw, 22px); }
#map-progress, #map-status { margin: 8px 0; font-size: .86rem; color: #41594c; }
.map-viewport { overflow: auto; max-height: 55dvh; background: #dbeef1; border: 1px solid #b5cdd0; border-radius: 9px; }
.map-viewport svg { display: block; width: 100%; max-width: none; }
.map-area { stroke: #718678; stroke-width: .5px; vector-effect: non-scaling-stroke; cursor: pointer; }
.map-area.map-selected { stroke: #be6333; stroke-width: 1.7px; }
.map-controls { display: grid; grid-template-columns: minmax(0, 1fr) 44px 44px; gap: 8px; margin-top: 10px; }
.map-controls select { min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: inherit; font: inherit; }
.map-credit { margin: 10px 0 0; font-size: .74rem; color: #566960; }
.map-credit a { color: inherit; }
@media (max-width: 500px) {
  .top { flex-wrap: wrap; }
  .top-actions { margin-left: auto; }
}
.save-actions { display: grid; gap: 8px; margin-top: 10px; }
.save-status { margin: 10px 0 0; color: var(--green); font-size: .85rem; }
.save-status:empty { margin: 0; }
.sound-setting { display: flex; min-height: 44px; align-items: center; gap: 8px; cursor: pointer; }
.sound-setting input { width: 19px; height: 19px; accent-color: var(--green); }
.map-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 8px 0 12px; }
.map-facts div { min-width: 0; padding: 7px 8px; border-radius: 7px; border: 1px solid var(--line); background: #fffaf0; }
.map-facts dt { margin-bottom: 3px; font-size: .72rem; color: #506759; }
.map-facts dd { margin: 0; font-size: .85rem; font-weight: 700; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.map-marker { stroke: #496c61; stroke-width: 1.2px; pointer-events: none; }
.map-marker-hit { fill: transparent; stroke: transparent; stroke-width: 32px; vector-effect: non-scaling-stroke; pointer-events: all; cursor: pointer; }
.map-nearby { margin: 8px 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fffaf0; }
.map-nearby h3 { margin: 0 0 5px; font-size: .85rem; }
#map-nearby-options { display: flex; flex-wrap: wrap; gap: 6px; }
#map-nearby-options button { padding-inline: 10px; }
