:root {
  --ink: #3b2c22;
  --ink-soft: rgba(59, 44, 34, 0.55);
  --serif: 'Shippori Mincho', 'Times New Roman', serif;
  --sans: 'Zen Kaku Gothic New', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dfcf; color: var(--ink); font-family: var(--sans); }
canvas { display: block; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 1.2s ease; text-align: center; padding: 16px;
}
.screen.show { opacity: 1; pointer-events: auto; }

#title { cursor: pointer; }
#title h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 12vw, 108px); letter-spacing: 0.08em; margin: 0; }
#title .sub { font-family: var(--serif); font-size: clamp(16px, 3vw, 20px); color: var(--ink-soft); margin: 6px 0 64px; letter-spacing: 0.12em; }
#title .tap { font-size: 15px; letter-spacing: 0.3em; text-transform: uppercase; animation: breathe 4s ease-in-out infinite; margin: 0; }
#title .hint { position: absolute; bottom: 28px; font-size: 13px; color: var(--ink-soft); letter-spacing: 0.08em; }
@keyframes breathe { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.9; } }


#hud {
  position: fixed; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; opacity: 0; pointer-events: none; transition: opacity 1s ease;
}
#hud.show { opacity: 1; pointer-events: auto; }
#hud button { font-size: 14px; letter-spacing: 0.08em; color: var(--ink-soft); padding: 10px 6px; transition: color 0.3s; }
#hud button:hover { color: var(--ink); }
#lvname { font-family: var(--serif); font-size: 18px; letter-spacing: 0.12em; }
#mute { position: fixed; top: 10px; right: 16px; font-size: 18px !important; z-index: 5; }
#mute.off { text-decoration: line-through; opacity: 0.5; }

#panel {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  width: min(560px, calc(100% - 32px)); text-align: center; opacity: 0; pointer-events: none;
  transition: opacity 1s ease, transform 1s ease;
}
#panel.show { opacity: 1; transform: translate(-50%, 0); }
#panel #dots, #panel #steptext, #panel #how { transition: opacity 0.26s ease; }
#panel.fade #dots, #panel.fade #steptext, #panel.fade #how { opacity: 0; }
#panel.mark #how { color: #8a4f2a; font-weight: 500; animation: breathe 2.6s ease-in-out infinite; }
#how { margin-top: 6px; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); }
#dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
#dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(59, 44, 34, 0.18); transition: background 0.6s, transform 0.6s; }
#dots span.past { background: rgba(59, 44, 34, 0.5); }
#dots span.now { background: var(--ink); transform: scale(1.35); }
#steptext { font-family: var(--serif); font-size: clamp(17px, 2.6vw, 21px); line-height: 1.55; letter-spacing: 0.02em; min-height: 3.1em; }

#finale {
  position: fixed; left: 0; right: 0; bottom: 6vh; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity 2.4s ease;
}
#finale.show { opacity: 1; }
#finale .romaji { font-size: 12px; letter-spacing: 0.4em; color: var(--ink-soft); margin-bottom: 4px; }
#finale .kanji { font-family: var(--serif); font-size: 30px; color: var(--ink-soft); }
#finale .kanji rt { font-size: 12px; letter-spacing: 0.15em; padding-bottom: 2px; }
#finale .fname { font-family: var(--serif); font-size: clamp(38px, 7vw, 56px); letter-spacing: 0.14em; margin: 2px 0 4px; }
#finale .done { font-size: 12px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--ink-soft); }
#finale button {
  margin-top: 26px; font-size: 14px; letter-spacing: 0.25em; text-transform: uppercase; padding: 12px 26px;
  border: 1px solid rgba(59, 44, 34, 0.3); border-radius: 999px; opacity: 0; transition: opacity 1.6s ease, background 0.4s;
}
#finale.ready { pointer-events: auto; }
#finale.ready button { opacity: 1; }
#finale button:hover { background: rgba(255, 252, 245, 0.5); }

/* ---------- mapa ---------- */
#menu { display: block; overflow-y: auto; overflow-x: hidden; padding: 0; text-align: center; }
#mapTop {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 56px 14px 16px; background: linear-gradient(#efe6d6 60%, rgba(239, 230, 214, 0));
}
#mapTop .book { font-family: var(--serif); font-size: 20px; letter-spacing: 0.14em; }
#mapTop .book small { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--ink-soft); }
#trophyBtn { font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-soft); padding: 8px 10px; }
#trophyBtn:hover { color: var(--ink); }
#map { position: relative; width: 100%; margin-top: -40px; }
.trail { position: absolute; top: 0; pointer-events: none; overflow: visible; }
.trail path { fill: none; stroke-linecap: round; }
.trail .todo { stroke: rgba(92, 64, 44, 0.22); stroke-width: 3; stroke-dasharray: 1 11; }
.trail .walked { stroke: rgba(92, 64, 44, 0.55); stroke-width: 3.2; stroke-dasharray: 14 9; }
.node {
  position: absolute; width: 96px; margin-left: -48px; margin-top: -48px; display: flex; flex-direction: column; align-items: center;
  transition: transform 0.5s ease;
}
.node .disc {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 40% 35%, #fffaf0, #efe4d1 70%, #e3d4bc);
  box-shadow: 0 6px 16px rgba(90, 60, 30, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font-family: var(--serif); font-size: 20px; color: rgba(59, 44, 34, 0.3);
}
.node .disc canvas { width: 64px; height: 64px; }
.node:not(.done) .disc canvas { filter: grayscale(1) brightness(1.12); opacity: 0.45; }
.node .nlabel { margin-top: 6px; font-family: var(--serif); font-size: 15px; letter-spacing: 0.06em; white-space: nowrap; }
.node .times { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.1em; }
.node.done .disc { box-shadow: 0 6px 16px rgba(90, 60, 30, 0.18), 0 0 0 2px rgba(185, 130, 79, 0.45), inset 0 1px 0 #fff; }
.node.locked { cursor: default; opacity: 0.5; }
.node.locked .nlabel { color: var(--ink-soft); }
.node:not(.locked):hover { transform: translateY(-3px); }
.node.current .disc::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 1.5px solid rgba(185, 110, 60, 0.6);
  animation: ripple 2.8s ease-out infinite;
}
.node.fresh .disc { animation: bloom 1.6s ease-out 0.6s both; }
@keyframes ripple { 0% { transform: scale(0.92); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes bloom { 0% { transform: scale(0.6); filter: brightness(1.3); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.banner { position: absolute; left: 0; right: 0; height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 14px; }
.banner .hills {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; width: min(560px, 100%); height: 70px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 25%, #000 75%, transparent); mask-image: linear-gradient(to right, transparent, #000 25%, #000 75%, transparent);
}
.banner .hills path { fill: rgba(120, 100, 80, 0.10); }
.banner .hills .far { fill: rgba(120, 100, 80, 0.07); }
.banner .bn { font-family: var(--serif); font-size: 44px; line-height: 1; position: relative; }
.banner .bt { font-family: var(--serif); font-size: 15px; letter-spacing: 0.18em; color: var(--ink-soft); position: relative; margin-top: 4px; }
.banner.locked { opacity: 0.45; }

/* ---------- curiosidades ---------- */
#note {
  position: fixed; left: 50%; bottom: 28px; width: min(440px, calc(100% - 32px)); z-index: 8;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 1s ease, transform 1s ease;
  background: rgba(252, 248, 240, 0.96); border-radius: 14px; padding: 18px 22px 16px; text-align: center;
  box-shadow: 0 14px 40px rgba(80, 55, 30, 0.18);
}
#note.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#note .ntitle { font-family: var(--serif); font-size: 22px; letter-spacing: 0.12em; }
#note .nsub { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: #a5683e; }
#note p { font-family: var(--serif); font-size: 16px; line-height: 1.6; margin: 10px 0 12px; }
#note button { font-size: 12px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--ink-soft); padding: 6px 12px; }

/* ---------- trofeos ---------- */
.seal {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px;
  font-family: var(--serif); font-size: 22px; color: #b8342a; border: 2px solid #b8342a; transform: rotate(-5deg);
}
#toast {
  position: fixed; top: 14px; left: 50%; z-index: 9; display: flex; gap: 14px; align-items: center; text-align: left;
  transform: translate(-50%, -30px); opacity: 0; transition: opacity 0.7s ease, transform 0.7s ease; pointer-events: none;
  background: rgba(252, 248, 240, 0.97); border-radius: 12px; padding: 12px 18px; font-size: 13px; line-height: 1.4;
  box-shadow: 0 10px 30px rgba(80, 55, 30, 0.18); max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast b { font-family: var(--serif); font-size: 16px; font-weight: 600; }
#trophies { justify-content: flex-start; overflow-y: auto; padding: 40px 16px; }
#trophies h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: 0.14em; margin: 0 0 4px; }
#tstats { font-size: 12px; letter-spacing: 0.15em; color: var(--ink-soft); margin-bottom: 26px; }
#tlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; width: min(820px, 100%); }
.trophy { display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 12px; background: rgba(255, 252, 245, 0.4); font-size: 13px; line-height: 1.4; color: var(--ink-soft); }
.trophy b { font-family: var(--serif); font-size: 15px; color: var(--ink); }
.trophy:not(.got) .seal { color: rgba(59, 44, 34, 0.22); border-color: rgba(59, 44, 34, 0.18); }
.trophy.got { background: rgba(255, 252, 245, 0.8); }
#tback { margin-top: 26px; font-size: 13px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--ink-soft); padding: 10px; }
