/* Dordo Story — dusk over the floating isles, a golden crest, and a quest scroll at the town gate */
:root {
  --dusk-1: #1b0b33;
  --dusk-2: #4a1f6b;
  --dusk-3: #c2477a;
  --dusk-4: #ff9a52;
  --gold-1: #fff3b0;
  --gold-2: #ffcf4a;
  --gold-3: #d9851a;
  --gold-4: #7a3a0c;
  --paper: #fbefd2;
  --paper-edge: #e7c98e;
  --ink: #4a2a14;
  --ink-soft: #7a5432;
  --wood-1: #a0632e;
  --wood-2: #5e3415;
  --maple: #ff7a1a;
  --maple-deep: #d84a0c;
  --good: #2f8a3a;
  --bad: #c0301e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--dusk-1);
  color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- the sky ---------- */
.sky {
  position: fixed; inset: 0; overflow: hidden; z-index: 0;
  background:
    radial-gradient(120% 70% at 50% 100%, rgba(255, 154, 82, .85) 0%, rgba(194, 71, 122, .7) 32%, transparent 62%),
    linear-gradient(180deg, var(--dusk-1) 0%, var(--dusk-2) 45%, var(--dusk-3) 78%, var(--dusk-4) 100%);
}
.sun {
  position: absolute; left: 50%; bottom: 14%; width: 46vmin; height: 46vmin; transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, #fff6c9 0%, #ffd27a 32%, rgba(255, 140, 70, .45) 55%, transparent 70%);
  filter: blur(2px);
  animation: sunPulse 9s ease-in-out infinite;
}
@keyframes sunPulse { 50% { transform: translateX(-50%) scale(1.06); opacity: .9; } }
.stars {
  position: absolute; inset: 0 0 45% 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent), radial-gradient(1px 1px at 28% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 44% 26%, #ffe9b0, transparent), radial-gradient(1px 1px at 63% 12%, #fff, transparent),
    radial-gradient(2px 2px at 78% 22%, #fff, transparent), radial-gradient(1px 1px at 90% 6%, #ffe9b0, transparent),
    radial-gradient(1px 1px at 6% 40%, #fff, transparent), radial-gradient(1.5px 1.5px at 54% 4%, #fff, transparent),
    radial-gradient(1px 1px at 36% 38%, #fff, transparent), radial-gradient(1.5px 1.5px at 86% 40%, #fff, transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
  mask-image: linear-gradient(#000, transparent);
  -webkit-mask-image: linear-gradient(#000, transparent);
}
@keyframes twinkle { to { opacity: .45; } }
.clouds { position: absolute; inset: 0; pointer-events: none; }
.clouds i {
  position: absolute; display: block; height: 60px; border-radius: 60px;
  background: linear-gradient(180deg, rgba(255, 220, 240, .55), rgba(255, 170, 200, .15));
  filter: blur(1px);
  animation: drift linear infinite;
}
.clouds i::before, .clouds i::after { content: ''; position: absolute; border-radius: 50%; background: inherit; }
.clouds i::before { width: 46%; height: 150%; left: 14%; top: -60%; }
.clouds i::after { width: 34%; height: 120%; left: 50%; top: -40%; }
.clouds.far i { opacity: .55; transform: scale(.7); }
.clouds.far i:nth-child(1) { top: 12%; width: 220px; animation-duration: 140s; animation-delay: -20s; }
.clouds.far i:nth-child(2) { top: 26%; width: 160px; animation-duration: 170s; animation-delay: -90s; }
.clouds.far i:nth-child(3) { top: 8%; width: 260px; animation-duration: 200s; animation-delay: -140s; }
.clouds.far i:nth-child(4) { top: 34%; width: 180px; animation-duration: 150s; animation-delay: -60s; }
.clouds.near i { opacity: .8; bottom: 6%; }
.clouds.near i:nth-child(1) { width: 340px; bottom: 4%; animation-duration: 90s; animation-delay: -10s; }
.clouds.near i:nth-child(2) { width: 260px; bottom: 12%; animation-duration: 110s; animation-delay: -60s; }
.clouds.near i:nth-child(3) { width: 420px; bottom: -2%; animation-duration: 80s; animation-delay: -40s; }
@keyframes drift { from { left: -460px; } to { left: 110%; } }
.isles { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; }
.isle { animation: bob 7s ease-in-out infinite; }
.isle.b { animation-duration: 9s; animation-delay: -3s; }
.isle.c { animation-duration: 6s; animation-delay: -1s; }
@keyframes bob { 50% { transform: translateY(-12px); } }
.castle { opacity: .9; }
.leaves { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- the front: crest + scroll ---------- */
.front {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  padding: max(24px, env(safe-area-inset-top)) 16px max(56px, env(safe-area-inset-bottom));
}
.crest { text-align: center; position: relative; animation: rise 1.1s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.9); } }
.crest-fox {
  width: 84px; height: 84px; object-fit: contain; display: block; margin: 0 auto -14px;
  filter: drop-shadow(0 4px 0 var(--gold-4)) drop-shadow(0 0 18px rgba(255, 207, 74, .7));
  animation: foxHop 3.2s ease-in-out infinite;
  position: relative; z-index: 2;
}
@keyframes foxHop { 0%, 70%, 100% { transform: translateY(0) rotate(0); } 78% { transform: translateY(-10px) rotate(-6deg); } 86% { transform: translateY(0) rotate(4deg); } }
.logo { margin: 0; line-height: .9; font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; }
.logo-top {
  display: block;
  font-size: clamp(54px, 15vw, 128px);
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 42%, var(--gold-3) 58%, #ffe08a 76%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--gold-4);
  filter: drop-shadow(0 5px 0 #4a1c05) drop-shadow(0 0 28px rgba(255, 190, 80, .55));
  position: relative;
}
.logo-top::after { /* a glint that sweeps the gold */
  content: 'DORDO'; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .95) 50%, transparent 60%) no-repeat;
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 0;
  animation: glint 5s ease-in-out infinite 1.2s;
}
@keyframes glint { 0% { background-position: 130% 0; } 30%, 100% { background-position: -130% 0; } }
.ribbon {
  display: inline-flex; align-items: center; gap: 10px; position: relative;
  margin-top: 6px; padding: 6px 34px 8px;
  background: linear-gradient(180deg, #ff8d3a, var(--maple-deep));
  border: 3px solid #6b1f04; border-radius: 6px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 6px 0 #4a1203, 0 10px 24px rgba(0, 0, 0, .35);
}
.ribbon::before, .ribbon::after { /* the ribbon's tails */
  content: ''; position: absolute; top: 12px; width: 26px; height: 100%;
  background: #b0360a; border: 3px solid #6b1f04; z-index: -1;
}
.ribbon::before { left: -20px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%); }
.ribbon::after { right: -20px; clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%); }
.ribbon b {
  font-size: clamp(22px, 6vw, 40px); letter-spacing: .35em; margin-right: -.35em; color: #fff8e6;
  text-shadow: 0 3px 0 #6b1f04;
}
.leaf {
  width: 22px; height: 22px; display: inline-block;
  background: var(--gold-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1l2 5 4-2-1 5 5-1-3 4 3 2-6 1 1 4-4-2-1 6-1-6-4 2 1-4-6-1 3-2-3-4 5 1-1-5 4 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1l2 5 4-2-1 5 5-1-3 4 3 2-6 1 1 4-4-2-1 6-1-6-4 2 1-4-6-1 3-2-3-4 5 1-1-5 4 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: spinLeaf 6s linear infinite;
}
.leaf.r { animation-direction: reverse; }
@keyframes spinLeaf { to { transform: rotate(360deg); } }
.tagline {
  margin: 14px 0 0; color: #ffe7c4; font-weight: 500; letter-spacing: .08em;
  font-size: clamp(14px, 3.6vw, 18px); text-shadow: 0 2px 6px rgba(40, 0, 40, .7);
}

/* the quest scroll */
.scroll { width: min(420px, calc(100% - 28px)); position: relative; animation: unroll .9s cubic-bezier(.2, .9, .3, 1.1) .35s both; }
@keyframes unroll { from { opacity: 0; transform: scaleY(.15); } }
.rod {
  height: 22px; margin: 0 -14px; position: relative; z-index: 2; border-radius: 11px;
  background: linear-gradient(180deg, #d08a4a, var(--wood-1) 40%, var(--wood-2));
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4), inset 0 2px 0 rgba(255, 255, 255, .3);
}
.rod::before, .rod::after { /* golden knobs */
  content: ''; position: absolute; top: -4px; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--gold-1), var(--gold-2) 40%, var(--gold-3) 75%, var(--gold-4));
  box-shadow: 0 3px 6px rgba(0, 0, 0, .4);
}
.rod::before { left: -14px; } .rod::after { right: -14px; }
.paper {
  margin: -8px 0; padding: 26px 24px 22px; position: relative;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, .55), transparent 60%),
    radial-gradient(80% 50% at 50% 100%, rgba(200, 150, 80, .25), transparent 70%),
    var(--paper);
  border-left: 3px solid var(--paper-edge); border-right: 3px solid var(--paper-edge);
  box-shadow: inset 0 0 40px rgba(170, 110, 40, .25), 0 20px 50px rgba(20, 0, 30, .5);
  min-height: 210px;
}
.pane { display: none; flex-direction: column; gap: 12px; }
.pane.on { display: flex; animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }
.pane h2 {
  margin: 0; text-align: center; font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 700;
  font-size: 22px; color: var(--ink);
}
.glyph { font-family: system-ui, sans-serif; }
.small { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-soft); }
.small b { color: var(--ink); }
.center { text-align: center; }
.foot { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.foot a, .links a { color: var(--maple-deep); font-weight: 600; }
.say { margin: 0; text-align: center; font-weight: 600; color: var(--ink-soft); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.field input {
  width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 16px; color: var(--ink);
  background: #fffaf0; border: 2px solid var(--paper-edge);
  box-shadow: inset 0 2px 4px rgba(120, 70, 20, .15);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--maple); box-shadow: inset 0 2px 4px rgba(120, 70, 20, .15), 0 0 0 3px rgba(255, 122, 26, .25); }
.msg { margin: 0; min-height: 1.3em; font-size: 14px; font-weight: 600; text-align: center; color: var(--ink-soft); }
.msg.good { color: var(--good); } .msg.bad { color: var(--bad); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* the big orange MapleStory-ish button */
.maple-btn {
  appearance: none; cursor: pointer; border: 0; position: relative;
  padding: 12px 22px; border-radius: 14px;
  font-weight: 700; font-size: 17px; letter-spacing: .04em; color: #fff;
  background: linear-gradient(180deg, #ffb35c 0%, var(--maple) 48%, var(--maple-deep) 52%, #b8400b 100%);
  border: 2px solid #7a2604;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 4px 0 #6b1f04, 0 8px 18px rgba(120, 40, 0, .35);
  text-shadow: 0 2px 0 rgba(107, 31, 4, .8);
  transition: transform .08s, filter .15s;
}
.maple-btn:hover { filter: brightness(1.08); }
.maple-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 1px 0 #6b1f04, 0 3px 8px rgba(120, 40, 0, .35); }
.maple-btn:disabled { filter: grayscale(.6); cursor: wait; }
.maple-btn span { opacity: .85; }
.maple-btn.big { font-size: 20px; padding: 16px 22px; overflow: hidden; }
.maple-btn.big::after { /* a shine that keeps passing over it */
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: shine 2.6s ease-in-out infinite;
}
@keyframes shine { 60%, 100% { left: 130%; } }
.sword { display: inline-block; margin-right: 6px; }
/* the other way in: as a monster spirit (purple, quieter than the big orange one) */
.maple-btn.spirit {
  font-size: 15px; padding: 10px 18px; margin-top: 4px;
  background: linear-gradient(180deg, #c79bff 0%, #8a4fe0 48%, #6d34c4 52%, #4f2096 100%);
  border-color: #33106a; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 4px 0 #2a0c58, 0 8px 18px rgba(60, 20, 120, .35);
  text-shadow: 0 2px 0 rgba(40, 10, 90, .8);
}
.maple-btn.spirit:active { box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 1px 0 #2a0c58, 0 3px 8px rgba(60, 20, 120, .35); }
.links { margin: 0; text-align: center; font-size: 13px; color: var(--ink-soft); }
.link { background: none; border: 0; padding: 0; color: var(--maple-deep); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.acct { font-weight: 600; color: var(--ink); }

.me { display: flex; align-items: center; gap: 14px; justify-content: center; }
.me-av {
  width: 64px; height: 64px; border-radius: 50%; padding: 4px; flex: none;
  background: conic-gradient(var(--gold-2), var(--maple), var(--gold-1), var(--maple-deep), var(--gold-2));
  animation: spinLeaf 8s linear infinite;
}
.me-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff3dc; animation: spinLeaf 8s linear infinite reverse; image-rendering: pixelated; }
.me small { display: block; color: var(--ink-soft); font-size: 13px; }
.me b { font-size: 26px; color: var(--ink); font-family: 'Cinzel Decorative', Georgia, serif; word-break: break-word; }

/* the swirling portal (waiting) */
.portal { width: 72px; height: 72px; margin: 6px auto; position: relative; }
.portal i { position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; }
.portal i:nth-child(1) { border-top-color: var(--maple); border-right-color: var(--gold-2); animation: spinLeaf 1.1s linear infinite; }
.portal i:nth-child(2) { inset: 10px; border-bottom-color: #9a5cff; border-left-color: #d58cff; animation: spinLeaf .8s linear infinite reverse; }
.portal i:nth-child(3) { inset: 22px; background: radial-gradient(circle, #fff, #ffd27a 40%, transparent 70%); animation: sunPulse 1.4s ease-in-out infinite; transform: none; }
.portal.big { width: 110px; height: 110px; }

.back { margin-top: 4px; }
.back a { color: #ffe7c4; text-decoration: none; font-weight: 600; font-size: 14px; opacity: .85; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.back a:hover { opacity: 1; text-decoration: underline; }
.credits {
  position: relative; z-index: 1; margin-top: -44px; padding: 0 16px 14px; text-align: center;
  font-size: 11px; color: rgba(255, 231, 196, .6);
}
.credits a { color: rgba(255, 231, 196, .85); }

/* ---------- the game ---------- */
.stage {
  position: fixed; inset: 0; z-index: 10; background: #000;
  display: flex; align-items: center; justify-content: center;
}
#canvas { display: block; outline: none; background: #000; cursor: none; }
/* phones: the whole game is a trackpad (see dordo.js); it sits over the canvas, under the loading veil and menu */
.trackpad { position: absolute; inset: 0; z-index: 1; touch-action: none; -webkit-user-select: none; user-select: none; }
/* phones: a D-pad and Jump / Attack in the empty space beside (or under) the game */
.touch-controls { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.tc-dpad, .tc-act, .tc-bar { position: absolute; pointer-events: auto; touch-action: none; }
.tc-bar .tc-btn { position: relative; }
.tc-dpad .tc-btn { pointer-events: none; } /* (the whole pad reads the finger, see dordo.js) */
.tc-dpad { width: 150px; height: 150px; }
.tc-act { width: 150px; height: 150px; }
.tc-btn {
  position: absolute; width: 52px; height: 52px; border-radius: 50%; padding: 0;
  border: 2px solid rgba(255, 207, 74, .55); background: rgba(30, 10, 40, .45); color: #ffe7c4;
  font: 700 18px 'Fredoka', system-ui, sans-serif; touch-action: none; -webkit-user-select: none; user-select: none;
}
.tc-btn.on { background: rgba(255, 122, 26, .6); }
.tc-dpad .up { left: 49px; top: 0; } .tc-dpad .down { left: 49px; bottom: 0; }
.tc-dpad .left { left: 0; top: 49px; } .tc-dpad .right { right: 0; top: 49px; }
/* ⚔ and JUMP side by side along the bottom (one thumb rocks between them), LOOT out of the way up top */
.tc-act .atk { width: 72px; height: 72px; left: 0; bottom: 0; font-size: 28px; }
.tc-act .jump { width: 72px; height: 72px; right: 0; bottom: 0; font-size: 15px; }
.tc-act .loot { width: 46px; height: 46px; left: 0; top: 10px; font-size: 11px; }
/* a monster spirit on a phone: LET GO (only while holding a monster) and the ring of towns, over ⚔ / JUMP */
.tc-spirit { position: absolute; display: flex; gap: 8px; pointer-events: auto; touch-action: none; }
.tc-spirit .tc-btn { position: static; }
.tc-spirit .letgo { width: 72px; border-radius: 26px; font-size: 13px; background: rgba(140, 60, 220, .6); border-color: #e0c4ff; }
.tc-spirit .towns { font-size: 22px; }
.crest-fox { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.crest-fox.unveil { animation: foxSpin .8s ease-out; }
@keyframes foxSpin { to { transform: rotate(360deg) scale(1.15); } }
.tc-act .chat { width: 46px; height: 46px; right: 0; top: 10px; font-size: 20px; }
/* streaming: watchers' emotes rise from random spots along the bottom of the game and fade out */
.stream-emotes { position: absolute; z-index: 2; pointer-events: none; overflow: hidden; }
.stream-emote {
  position: absolute; bottom: 4%; display: flex; flex-direction: column; align-items: center;
  animation: emoteRise 2.8s cubic-bezier(.2, .7, .4, 1) forwards; will-change: transform, opacity;
}
.stream-emote i { font-style: normal; font-size: clamp(26px, 5vmin, 44px); line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.stream-emote b {
  margin-top: 2px; padding: 1px 6px; border-radius: 8px; font: 700 11px 'Fredoka', system-ui, sans-serif;
  color: #fff; background: rgba(60, 20, 90, .7); white-space: nowrap;
}
@keyframes emoteRise {
  0% { transform: translateY(20px) scale(.5); opacity: 0; }
  12% { transform: translateY(0) scale(1.1); opacity: 1; }
  25% { transform: translateY(-20px) scale(1); }
  80% { opacity: 1; }
  100% { transform: translateY(-36vh) translateX(var(--sway)) scale(.9); opacity: 0; }
}
/* phones typing into the game: a bar along the top (the phone's keyboard comes up from the bottom) */
.type-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 2147483100; display: flex; gap: 8px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(40, 46, 66, .97), rgba(22, 24, 36, .97)); border-bottom: 2px solid var(--gold-3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5); animation: typeIn .18s ease-out;
}
.type-bar[hidden] { display: none; }
@keyframes typeIn { from { transform: translateY(-100%); } }
.type-bar input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid #8b93ab;
  background: #fbefd2; color: var(--ink); font: 600 16px 'Fredoka', system-ui, sans-serif; outline: none;
}
.type-bar input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(255, 207, 74, .35); }
.type-bar button {
  height: 40px; padding: 0 14px; border-radius: 8px; font: 700 15px 'Fredoka', system-ui, sans-serif; color: #fff;
  border: 1px solid rgba(0, 0, 0, .4); touch-action: manipulation;
}
.type-send { background: linear-gradient(180deg, var(--maple), var(--maple-deep)); }
.type-send[hidden] { display: none; }
.type-done { background: linear-gradient(180deg, #5b6380, #3a4058); }
/* the quick slot's eight keys, laid out like the game's (two rows of four: left half, right half), each showing
   what's on it with the game's own icon; a tap pops it */
.tc-bar { display: grid; grid-template-columns: repeat(2, auto); gap: 5px; padding: 5px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(40, 46, 66, .85), rgba(18, 20, 32, .85)); border: 1px solid rgba(160, 175, 210, .35); }
.tc-bar.row { grid-template-columns: repeat(4, auto); }
.tc-slot {
  position: relative; width: 44px; height: 44px; border-radius: 6px; border: 1px solid #8b93ab;
  background: linear-gradient(180deg, #4d5570, #2a2f42); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 -2px 4px rgba(0, 0, 0, .5);
  transition: transform .08s;
}
.tc-slot canvas { position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; transform: translate(-50%, -50%); image-rendering: pixelated; pointer-events: none; }
.tc-slot b {
  position: absolute; right: 2px; bottom: 0; font: 700 11px/1 'Fredoka', system-ui, sans-serif; color: #fff; pointer-events: none;
  text-shadow: 0 0 2px #000, 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000;
}
/* which key it is, small in the corner as the game's slots show it */
.tc-slot i {
  position: absolute; left: 2px; top: 1px; font: 700 8px/1 'Fredoka', system-ui, sans-serif; font-style: normal;
  color: #e8ecff; pointer-events: none; z-index: 1; letter-spacing: .02em;
  text-shadow: 0 0 2px #000, 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000;
}
.tc-slot.on { background: linear-gradient(180deg, #ffd27a, #e08a1e); border-color: #fff3b0; }
.tc-slot.pop { animation: slotPop .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes slotPop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 220, 120, .55); }
  40% { transform: scale(1.1); box-shadow: 0 0 5px 1px rgba(255, 220, 120, .55); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 220, 120, 0); }
}
.summon {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #000;
  transition: opacity .8s;
}
/* loading: Dart's face spinning, "Loading..." in the crest's gold, and nothing else */
.summon-fox { display: block; width: 96px; height: 96px; margin: 0 auto 18px; object-fit: contain; }
.summon-fox.spin { animation: foxSpin 1.4s linear infinite; }
@keyframes foxSpin { to { transform: rotate(360deg); } }
.summon.gone { opacity: 0; pointer-events: none; }
.summon-box { text-align: center; color: #ffe7c4; max-width: 380px; }
.summon-box b {
  display: block; font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: 26px; letter-spacing: .04em;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 45%, var(--gold-3) 60%, #ffe08a 80%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #4a1c05);
}
.summon-box p { margin: 8px 0 12px; font-weight: 500; }
.summon-box small { display: block; margin-top: 12px; opacity: .7; font-size: 12.5px; }
.summon-detail {
  margin: 12px 0 0; padding: 8px 10px; max-height: 140px; overflow: auto; text-align: left;
  background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 207, 74, .3); border-radius: 8px;
  color: #ffd9b0; font-size: 11px; white-space: pre-wrap; word-break: break-word; user-select: text;
}
#summonBack { margin-top: 14px; }
.bar { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; border: 1px solid rgba(255, 207, 74, .4); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--maple), var(--gold-2)); transition: width .3s; }
.bar.busy i { width: 35% !important; animation: busy 1.3s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
/* a monster spirit on its way in: a swirling void over the character screen it skips, until the map shows */
/* between maps (after the fade to black): a hopping Orange Mushroom, a maple bar, a word on what's happening */
.map-loader {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; background: #000; color: #ffe7c4; opacity: 0; transition: opacity .35s; pointer-events: none;
}
.map-loader.on { opacity: 1; }
.ml-scene { position: relative; width: 180px; height: 120px; }
.ml-mush {
  position: absolute; left: 50%; bottom: 10px; width: 120px; height: 100px; margin-left: -60px;
  animation: mlHop .62s cubic-bezier(.3, 0, .5, 1) infinite alternate;
}
.ml-leaf { position: absolute; left: 50%; bottom: 22px; font-size: 44px; margin-left: -22px; animation: mlSpin 1.6s linear infinite; }
.ml-shadow {
  position: absolute; left: 50%; bottom: 4px; width: 64px; height: 10px; margin-left: -32px; border-radius: 50%;
  background: radial-gradient(rgba(255, 207, 74, .28), transparent 70%); animation: mlShadow .62s cubic-bezier(.3, 0, .5, 1) infinite alternate;
}
@keyframes mlHop { from { transform: translateY(0); } to { transform: translateY(-26px); } }
@keyframes mlShadow { to { transform: scale(.6); opacity: .5; } }
@keyframes mlSpin { to { transform: rotate(360deg); } }
.ml-title {
  font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: 24px; letter-spacing: .08em;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 45%, var(--gold-3) 60%, #ffe08a 80%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 0 #4a1c05);
}
.ml-title::after { content: '…'; }
.ml-bar {
  position: relative; width: min(340px, 80vw); height: 18px; border-radius: 10px; padding: 3px;
  background: linear-gradient(180deg, var(--wood-2), #2e1608); border: 2px solid var(--gold-3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6), 0 0 14px rgba(255, 154, 82, .25);
}
.ml-bar i {
  display: block; height: 100%; width: 0; border-radius: 6px; transition: width .25s ease-out;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .22) 0 6px, transparent 6px 12px),
    linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 40%, var(--maple) 60%, var(--maple-deep) 100%);
  background-size: 17px 17px, auto; animation: mlStripes .7s linear infinite;
}
@keyframes mlStripes { to { background-position: 17px 0, 0 0; } }
.ml-tip { position: absolute; top: 50%; left: 3px; font-size: 18px; transform: translate(-50%, -50%); transition: left .25s ease-out; filter: drop-shadow(0 1px 2px #000); }
.ml-say { margin: 4px 0 0; max-width: 340px; text-align: center; font-size: 13.5px; font-weight: 500; opacity: .85; }
.spirit-void {
  position: absolute; inset: 0; z-index: 2; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #12002a 0%, #05000f 70%);
  transition: opacity .9s;
}
.spirit-void.going { opacity: 0; }
.void-swirl {
  position: absolute; width: 160vmax; height: 160vmax; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 8%, rgba(138, 79, 224, .55) 14%, transparent 22% 33%,
    rgba(90, 40, 200, .45) 40%, transparent 48% 58%, rgba(200, 140, 255, .4) 66%, transparent 74% 84%, rgba(110, 50, 210, .5) 92%, transparent);
  -webkit-mask: radial-gradient(circle, transparent 4%, #000 22%, #000 40%, transparent 62%);
  mask: radial-gradient(circle, transparent 4%, #000 22%, #000 40%, transparent 62%);
  filter: blur(6px); animation: void-spin 6s linear infinite;
}
.void-swirl.two { width: 110vmax; height: 110vmax; animation-duration: 3.8s; animation-direction: reverse; opacity: .7; }
.void-core {
  position: absolute; width: 18vmin; height: 18vmin; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, rgba(255, 255, 255, .85), rgba(200, 170, 255, .35) 30%, rgba(90, 40, 200, .25) 70%, transparent 72%);
  box-shadow: 0 0 60px 20px rgba(150, 90, 255, .35); animation: void-pulse 2.4s ease-in-out infinite;
}
.spirit-void p {
  position: absolute; bottom: 12%; margin: 0; color: #e9dcff; font: 600 clamp(14px, 2.4vmin, 20px) system-ui, sans-serif;
  letter-spacing: .08em; text-shadow: 0 0 12px rgba(150, 90, 255, .9); animation: void-pulse 2.4s ease-in-out infinite;
}
@keyframes void-spin { to { transform: rotate(360deg); } }
@keyframes void-pulse { 50% { transform: scale(1.08); opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .void-swirl, .void-core, .spirit-void p { animation: none; } }

/* a monster spirit's ring of towns (R3 or middle-click): twelve towns round a dial, picked with the right stick
   or the mouse */
.spirit-ring {
  position: fixed; inset: 0; z-index: 2147483000; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(40, 10, 80, .55), rgba(10, 0, 30, .7)); cursor: default;
}
/* L3 held: a bar filling up, then a pop to Maple Island */
.spirit-charge {
  position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%); z-index: 2147482000; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: #e9dcff;
  font: 600 13px system-ui, sans-serif; text-shadow: 0 0 8px rgba(150, 90, 255, .9);
}
.spirit-charge div { width: min(46vw, 280px); height: 12px; border-radius: 8px; overflow: hidden;
  background: rgba(20, 5, 45, .75); border: 1px solid rgba(200, 160, 255, .6); }
.spirit-charge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a4fe0, #ffd84a); }
/* Y held: the spirit glows brighter and brighter (the edges of the screen too) until it pops somewhere random */
.spirit-glow {
  position: fixed; inset: 0; z-index: 2147481000; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, transparent 35%, rgba(170, 110, 255, .55) 80%, rgba(255, 230, 160, .8) 100%);
  mix-blend-mode: screen;
}
.ring-dial { position: relative; width: min(78vmin, 520px); height: min(78vmin, 520px); }
.ring-dial button {
  position: absolute; width: 19%; aspect-ratio: 1; margin: -9.5% 0 0 -9.5%; border-radius: 50%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px;
  border: 2px solid rgba(200, 160, 255, .55); background: rgba(40, 15, 80, .75); color: #f1e6ff;
  font: 600 clamp(9px, 1.9vmin, 13px)/1.1 system-ui, sans-serif; text-align: center;
  transition: transform .12s, background .12s, border-color .12s;
}
.ring-dial button span { font-size: clamp(16px, 4vmin, 28px); }
.ring-dial button.on { transform: scale(1.18); background: rgba(138, 79, 224, .92); border-color: #ffd84a; box-shadow: 0 0 18px rgba(255, 216, 74, .55); }
.ring-hub {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
  color: #fff; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .7);
}
.ring-hub b { font-size: clamp(18px, 4vmin, 30px); }
.ring-hub small { font-size: 11px; opacity: .75; }

/* Darty popping in to say which game controller just plugged in (and what does what) */
.pad-toast {
  position: absolute; z-index: 3; top: calc(max(8px, env(safe-area-inset-top)) + 46px); right: max(8px, env(safe-area-inset-right));
  display: flex; align-items: flex-end; gap: 4px; max-width: min(360px, calc(100vw - 16px)); pointer-events: none;
  animation: pad-in .45s cubic-bezier(.2, 1.4, .4, 1); transition: opacity .6s, transform .6s;
}
.pad-toast.going { opacity: 0; transform: translateX(30px); }
.pad-toast img { height: 128px; width: auto; flex: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }
.pad-toast > div {
  background: var(--paper); color: var(--ink); border: 2px solid var(--wood-2); border-radius: 12px 12px 12px 2px;
  padding: 10px 12px; margin-bottom: 26px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); font-size: 13px; line-height: 1.35;
}
.pad-toast b { display: block; font-size: 15px; margin-bottom: 4px; }
.pad-toast p { margin: 0; }
@keyframes pad-in { from { opacity: 0; transform: translateX(40px) scale(.9); } }
.hud { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); z-index: 3; }
.hud-btn {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 18px;
  background: rgba(30, 10, 40, .55); border: 1px solid rgba(255, 207, 74, .5); color: #fff;
  opacity: .45; transition: opacity .2s;
}
.hud-btn:hover, .hud-btn[aria-expanded="true"] { opacity: 1; }
.hud-menu {
  position: absolute; right: 0; top: 44px; display: flex; flex-direction: column; min-width: 200px;
  background: var(--paper); border: 2px solid var(--wood-2); border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.hud-menu button { background: none; border: 0; padding: 12px 16px; text-align: left; cursor: pointer; color: var(--ink); font-weight: 600; }
.hud-menu button:hover { background: rgba(255, 122, 26, .15); }

@media (max-height: 640px) and (min-width: 700px) {
  .front { flex-direction: row; gap: 40px; }
  .crest-fox { width: 64px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
