:root {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: #f8f2df;
  background: #1d382e;
  color-scheme: dark;
  --accent: #edc68b;
  --muted: #c4d0bf;
  --line: #64816b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button:active { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: default; }
button svg, .intro svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.game { max-width: 620px; margin: auto; height: 100svh; min-height: 500px; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom)); gap: 12px; }
.masthead { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.brand { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; text-decoration: none; color: inherit; font-size: 23px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.settings-button { min-height: 44px; display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; background: transparent; color: var(--muted); font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.mission { display: flex; gap: 12px; align-items: center; padding: 4px 0 6px; }
.sample { width: 62px; height: 62px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff07; flex-shrink: 0; display: grid; place-items: center; }
.sample canvas { width: 66px; height: 56px; }
.mission-copy { flex: 1; min-width: 0; }
.mission-label { display: block; font-size: 14px; color: var(--muted); }
h1 { font-size: clamp(17px, 4.8vw, 22px); font-weight: 700; margin: 5px 0 0; letter-spacing: .02em; }
.mission-numbers { align-self: center; text-align: right; font-variant-numeric: tabular-nums; }
#timer { display: block; font-size: 20px; margin-top: 3px; }
.finds { color: #ffedbb; font-size: 15px; }
#timer[hidden], #result-ranking[hidden] { display: none; }
.play-area { display: flex; flex-direction: column; flex: 1; min-height: 180px; }
.tray { position: relative; flex: 1; min-height: 160px; overflow: hidden; border-radius: 28px; background: #b18a54; box-shadow: 0 10px 24px #0b211c33; isolation: isolate; }
#field { position: absolute; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 28px; }
.tray-grain { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 4px #9a743f, inset 0 0 0 7px #d2b58388, inset 0 5px 13px #49391d44; z-index: 1; }
.intro { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; color: #f8f2df; background: #1d382ef2; padding: 11px 15px; border-radius: 12px; pointer-events: none; white-space: nowrap; font-size: 14px; transition: opacity .2s; box-shadow: 0 4px 12px #0002; }
.intro svg { color: var(--accent); }
.feedback { flex: 0 0 48px; display: grid; place-items: center; text-align: center; font-size: 14px; line-height: 1.4; padding: 4px 0 0; color: var(--muted); }
footer { display: flex; gap: 12px; }
footer button { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; white-space: nowrap; }
.secondary { border: 1px solid var(--line); color: #f8f2df; border-radius: 12px; background: transparent; padding: 12px 14px; font-size: 14px; min-height: 44px; }
.hint-button { color: #23372d; background: var(--accent); border-radius: 12px; font-size: 15px; font-weight: 700; }
.text-button { background: none; color: #e4eadb; font-size: 14px; padding: 12px 8px; min-height: 44px; }
.stage { font-size: 12px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
.result { position: absolute; inset: 0; background: #1d382e66; backdrop-filter: blur(3px); z-index: 3; display: grid; place-items: center; padding: 18px; }
.result[hidden] { display: none; }
.result-card { width: min(100%, 310px); max-height: 100%; overflow: auto; padding: 12px 14px 6px; background: #1d382e; border: 1px solid var(--line); border-radius: 18px; text-align: center; box-shadow: 0 20px 50px #0004; animation: discovery .22s ease-out; }
.result h2 { font-family: "Yu Mincho", serif; font-size: clamp(20px, 6vw, 30px); margin: 4px 0 8px; color: #ffe7a9; }
.result p { font-size: 14px; font-variant-numeric: tabular-nums; margin: 0 0 8px; color: var(--muted); }
.primary { width: 100%; background: var(--accent); color: #23372d; border-radius: 12px; padding: 14px 18px; min-height: 48px; font-weight: 700; }
.result .text-button { margin-top: 6px; }
.result .primary { padding-inline: 8px; }
.result-links { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 8px; }
dialog { background: #233e31; color: #f8f2df; border: 1px solid var(--line); border-radius: 22px; padding: 24px; width: min(440px, calc(100% - 28px)); max-height: 90svh; overflow: auto; box-shadow: 0 20px 80px #0005; }
dialog::backdrop { background: #0b1a13b3; backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-header h2 { font-size: 21px; margin: 0; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; background: #ffffff09; color: inherit; font-size: 27px; line-height: 1; flex-shrink: 0; }
dialog p { font-size: 16px; line-height: 1.8; }
dialog label { font-size: 16px; display: block; margin-top: 18px; }
output { float: right; color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 44px; }
dialog .small { font-size: 14px; color: var(--muted); }
.seed-control { border-top: 1px solid var(--line); padding-bottom: 10px; }
.seed-control input { width: 100%; background: #14261b; color: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; font-size: 16px; }
.seed-control .secondary { width: 100%; }
@keyframes discovery { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 700px) { .game { padding: 20px 30px; gap: 16px; } .brand { font-size: 26px; } }
@media (max-width: 350px) { .game { padding-left: 12px; padding-right: 12px; gap: 8px; } .brand { font-size: 21px; } .mission { gap: 8px; } .sample { width: 50px; height: 54px; } .intro { padding: 10px; font-size: 12px; } }
@media (max-height: 650px) { .game { gap: 7px; padding-top: 6px; padding-bottom: 8px; } .mission { padding: 0; } .sample { height: 52px; } }
@media (max-height: 500px) and (min-width: 600px) { .game { max-width: 820px; min-height: 340px; padding-left: 18px; padding-right: 18px; display: grid; grid-template-columns: 300px 1fr; grid-template-rows: auto auto 1fr; gap: 8px 20px; } .masthead, .mission, footer { grid-column: 1; } .play-area { grid-column: 2; grid-row: 1 / 4; min-height: 0; } .tray { max-width: calc(66.6667svh - 43px); width: 100%; align-self: center; } footer { flex-direction: column; justify-content: end; } footer button { flex: none; } .brand { font-size: 20px; } h1 { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { .intro { transition: none; } .result-card { animation: none; } }

.header-actions, .stage-picker, .toolbelt { display: flex; align-items: center; gap: 6px; }
.header-actions { flex-shrink: 0; }
.header-actions .settings-button { padding-inline: 6px; }
#ranking-open { color: var(--accent); }
.stage-picker { min-height: 48px; gap: 8px; font-size: 13px; color: var(--muted); }
#roadmap-open {
  flex: 1; display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 9px; min-width: 0; min-height: 48px; border: 1px solid var(--line);
  border-radius: 12px; padding: 5px 8px; text-align: left; color: inherit; background: #172e25;
}
#roadmap-open svg { color: var(--accent); }
#roadmap-open small, #roadmap-open strong { display: block; }
#roadmap-open small { font-size: 12px; }
#roadmap-open strong { color: #f8f2df; font-size: 14px; }
#roadmap-open .chevron { width: 16px; }
#stage-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.toolbelt button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 44px; border-radius: 9px; border: 1px solid var(--line); padding: 4px; background: #172e25; color: #f8f2df; font-size: 13px; white-space: nowrap; }
.toolbelt button[aria-pressed=true] { background: #dce7cf; color: #1d382e; border-color: #dce7cf; font-weight: 700; }
.toolbelt button[data-tool=lens][aria-pressed=true] { background: #f0d5a5; border-color: #f0d5a5; }
@media (prefers-reduced-motion: no-preference) {
  .is-pinching path { transform-origin: 12px 3px; animation: pinch .26s ease-out; }
  .is-pinching .pinch-left { --close: -13deg; }
  .is-pinching .pinch-right { --close: 13deg; }
}
@keyframes pinch { 45% { transform: rotate(var(--close)); } }
.tray { min-height: 130px; }
.game { min-height: 520px; gap: 8px; }
footer { gap: 6px; }
footer button { min-width: 0; padding-inline: 4px; }
.audio-settings { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#ranking select, .profile input, #players select {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px; margin-top: 6px; background: #172e25; color: inherit;
}
.rank-list { margin: 0; padding-left: 28px; }
.rank-list li { padding: 8px 0 8px 4px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.rank-list li strong { display: block; color: var(--accent); font-variant-numeric: tabular-nums; }
.trial-stage { margin: 12px 0 0; color: var(--accent); font-weight: 700; font-size: 19px; }
#ranking-note { margin-top: 4px; }
.profile { border-top: 1px solid var(--line); margin-top: 12px; }
.profile input[aria-invalid=true] { border-color: #ffc5ab; }
.profile p:empty { display: none; }
.profile #trial { margin-top: 14px; }
#rank-player { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 12px; }
#rank-player p { margin: 0; font-size: 14px; }
#rank-player strong { display: inline-block; overflow-wrap: anywhere; }
#player-add { margin-top: 14px; }
.player-list { padding: 0; margin: 8px 0; list-style: none; }
.player-list li { margin-bottom: 7px; }
.player-list button { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; text-align: left; overflow-wrap: anywhere; }
.player-list button[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
#rank-history { border-top: 1px solid var(--line); margin-top: 16px; }
#rank-history summary { min-height: 44px; line-height: 44px; color: var(--accent); cursor: pointer; }
#roadmap { width: min(520px, calc(100% - 24px)); padding: 20px; }
.road-summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
  border-radius: 10px; padding: 10px 12px; background: #e9cd98; color: #26352a;
  font-size: 14px;
}
.road-level { margin: 18px 0 0 13px; padding: 0 0 2px 17px; border-left: 1px solid #a08e65; }
.road-level h3 { position: relative; margin: 0; min-height: 32px; display: flex; align-items: center; font-size: 17px; }
.road-medal {
  position: absolute; left: -33px; display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid #a08e65; border-radius: 50%; background: #243c30; color: #dbc798;
}
.road-medal.is-earned { background: #edc68b; color: #26352a; }
.road-medal svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.road-progress { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }
.road-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.road-practice { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 12px; }
.road-tile {
  display: flex; gap: 4px; align-items: center; min-width: 0; min-height: 64px;
  border: 1px solid var(--line); border-radius: 10px; padding: 5px; text-align: left;
  background: #172e25; color: #f8f2df; overflow-wrap: anywhere;
}
.road-tile[aria-current=step] { border-color: var(--accent); }
.road-tile:disabled { opacity: .76; background: transparent; }
.road-tile canvas { width: 32px; height: 32px; flex-shrink: 0; }
.road-tile strong, .road-tile small { display: block; line-height: 1.32; }
.road-tile strong { font-size: 14px; }
.road-tile small { font-size: 12px; margin-top: 3px; color: var(--muted); }
@media (max-width: 390px) { .brand { font-size: clamp(15px, 4.85vw, 20px); } .masthead { gap: 4px; } .header-actions { gap: 0; } .header-actions .settings-button { padding-inline: 5px; font-size: 12px; } }
@media (max-width: 350px) { #roadmap { padding: 14px; } .road-tile canvas { width: 26px; height: 26px; } }
@media (max-width: 419px) {
  .toolbelt button { flex-direction: column; gap: 0; min-height: 48px; }
  .toolbelt button svg { width: 19px; height: 19px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .game { min-height: 350px; grid-template-rows: repeat(4, auto) 1fr; }
  .stage-picker, .toolbelt { grid-column: 1; }
  .play-area { grid-row: 1 / 6; }
  footer { flex-direction: row; align-self: end; justify-content: stretch; }
  footer button { flex: 1 1 0; }
  .toolbelt button { flex-direction: column; gap: 0; }
  .result { padding: 8px; }
}

.home {
  max-width: 540px; min-height: 100svh; margin: auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom));
}
.home-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 4px 0 12px; }
.home-header h1 {
  margin: 0; font: 700 clamp(25px, 7vw, 35px) / 1.35 "Yu Mincho", "Hiragino Mincho ProN", serif;
  letter-spacing: .025em;
}
.home-tray {
  overflow: hidden; border: 1px solid #bc995e; border-radius: 23px;
  background: #d2af74; color: #2c382c; box-shadow: 0 13px 26px #11241b77;
}
#home-art { display: block; width: 100%; height: auto; }
.home-invitation { padding: 0 14px 13px; text-align: center; }
.home-invitation p { margin: 0 0 10px; font: 700 17px/1.45 "Yu Mincho", serif; }
#home-play { display: grid; justify-items: start; gap: 4px; text-align: left; background: #244637; color: #fff2d5; }
#home-play strong { font-size: 17px; }
#home-play span { font-size: 14px; color: #e5d8b7; font-weight: 400; }
.home-navigation { margin-top: 15px; border-top: 1px solid var(--line); }
.home-navigation button {
  display: grid; width: 100%; min-height: 62px; grid-template-columns: 31px minmax(0, 1fr) auto;
  align-items: center; gap: 9px; text-align: left; background: transparent; color: inherit;
  padding: 8px 5px; border-bottom: 1px solid var(--line);
}
.home-navigation button svg { color: var(--accent); }
.home-navigation button span:last-child { color: var(--accent); font-size: 24px; line-height: 1; }
.home-navigation strong, .home-navigation small { display: block; overflow-wrap: anywhere; }
.home-navigation strong { font-size: 16px; }
.home-navigation small { margin-top: 3px; font-size: 14px; color: var(--muted); }
.home-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.home-footer .text-button { padding-left: 5px; }

#public-ranking { width: min(510px, calc(100% - 16px)); }
#public-ranking label { margin-top: 12px; }
#public-ranking input, #public-ranking select {
  width: 100%; min-height: 44px; margin-top: 5px; padding: 8px;
  color: inherit; border: 1px solid var(--line); border-radius: 9px; background: #172e25;
}
#public-status:empty, #public-empty:empty { display: none; }
.public-block { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.public-block .secondary { margin-top: 7px; }
.public-privacy h3 { margin: 0 0 6px; }
.public-privacy p { margin: 0 0 8px; }
.public-periods { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.public-periods button {
  min-height: 44px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 8px;
  background: #172e25; color: inherit; font-size: 14px;
}
.public-periods button[aria-pressed=true] { background: var(--accent); color: #22382e; font-weight: 700; }
#public-period-date { margin: 5px 0 0; }
#public-period-date:empty { display: none; }
#public-erase summary { min-height: 44px; padding: 12px 0; cursor: pointer; color: var(--muted); }
#public-account-name, .public-record-name { overflow-wrap: anywhere; }
.public-record { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
.public-record .text-button { color: var(--muted); padding: 6px; }
.public-round-head { display: flex; align-items: center; gap: 8px; margin-block: 10px; }
.public-round-head canvas { width: 46px; height: 46px; flex-shrink: 0; background: #172e25; border-radius: 8px; }
.public-round-head h3, .public-round-head p { margin: 0; }
.public-round-head h3 { font-size: 15px; }
.public-round-head p { font-size: 14px; color: var(--muted); }
#public-clock { margin-left: auto; font-variant-numeric: tabular-nums; }
#public-found { white-space: nowrap; color: var(--accent); }
.public-slots {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px;
  padding: 5px; border-radius: 14px; background: #a87d4d;
}
.public-slot {
  display: grid; place-items: center; min-height: 44px; aspect-ratio: 1; padding: 0;
  background: #c8a470; border-radius: 7px;
}
.public-slot:disabled { opacity: .56; }
.public-slot canvas { display: block; width: 100%; max-width: 60px; }
#public-retry { margin-top: 8px; }
@media (max-width: 390px) { #public-ranking { padding: 9px; } }
@media (max-width: 350px) { #public-ranking { width: calc(100% - 8px); padding: 6px; } }
@media (max-width: 360px) {
  .home { padding-inline: 12px; }
  .home-header h1 { font-size: 25px; }
}
@media (max-height: 530px) and (min-width: 650px) {
  .home { max-width: 780px; display: grid; grid-template-columns: 1.15fr 1fr; gap: 6px 20px; align-content: start; }
  .home-header { grid-column: 1 / -1; margin: 0; }
  .home-tray { grid-row: 2 / 4; }
  .home-navigation { margin-top: 4px; }
  .home-footer { grid-column: 2; align-self: start; }
}
