:root {
  --cream: #fff8ec;
  --cream-2: #f7ead3;
  --paper: #fffdf8;
  --wood: #6b4226;
  --wood-d: #4a2c18;
  --ink: #3a2a1f;
  --ink-soft: #7a6352;
  --green: #3aa35b;
  --green-d: #2a7c44;
  --orange: #f08a24;
  --orange-d: #c96a10;
  --red: #e0453a;
  --blue: #3a7bd5;
  --yellow: #f5c542;
  --purple: #8a5ab8;
  --shadow: 0 6px 18px rgba(40, 22, 8, .28);
  --r: 18px;
  --font: 'Baloo 2', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b1d14; font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
button { font-family: inherit; }
input, textarea { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
.input-zone { position: fixed; inset: 0; z-index: 5; pointer-events: auto; touch-action: none; }

/* ------------------------------------------------------------ loading */
#loading { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #f6c77f 0%, #d9793a 45%, #6b3319 100%); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.load-card { text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.load-card h1 { font-size: clamp(48px, 9vw, 96px); margin: 0; letter-spacing: 1px; line-height: 1; }
.load-logo { width: 140px; height: 140px; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0,0,0,.3)); }
.load-sub { margin: 4px 0 24px; font-size: 22px; opacity: .95; }
.load-bar { width: min(420px, 70vw); height: 18px; border-radius: 12px; background: rgba(0,0,0,.25); overflow: hidden; margin: 0 auto; border: 3px solid rgba(255,255,255,.6); }
#load-fill, #rotate-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffe08a, #fff); border-radius: 12px; transition: width .25s; }
#load-text { font-size: 16px; opacity: .9; }

#rotate-hint { display: none; position: fixed; inset: 0; z-index: 200; background: #2b1d14; color: #fff; place-items: center; align-content: center; gap: 14px; text-align: center; font-size: 20px; padding: 30px; }
#rotate-hint p { margin: 0; }
#rotate-hint .rotate-icon { font-size: 64px; }
#rotate-text { font-size: 16px; opacity: .8; }
@media (orientation: portrait) and (max-width: 700px) { #rotate-hint { display: grid; } }

/* ------------------------------------------------------------ HUD */
.hud-tl { position: fixed; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l)); display: flex; gap: 10px; align-items: flex-start; }
.portrait { width: 64px; height: 64px; border-radius: 50%; background: var(--cream) center/cover; border: 4px solid #fff; box-shadow: var(--shadow); cursor: pointer; position: relative; overflow: hidden; display: grid; place-items: center; font-size: 30px; }
.portrait canvas, .portrait img { width: 100%; height: 100%; object-fit: cover; }
.hud-stack { display: flex; flex-direction: column; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(43, 29, 20, .78); color: #fff; border-radius: 999px; padding: 3px 14px 3px 4px; font-weight: 700; font-size: 18px; box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.pill .ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); font-size: 16px; }
.pill .ico img { width: 26px; height: 26px; }
.pill.money { cursor: pointer; }
.pill.money .val { min-width: 48px; }
.pill.money .plus { width: 22px; height: 22px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-size: 17px; line-height: 1; margin: 0 -9px 0 auto; }
.pill.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.18); } }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: flex; align-items: center; gap: 6px; background: rgba(43, 29, 20, .7); border-radius: 999px; padding: 2px 8px 2px 3px; color: #fff; font-size: 13px; font-weight: 700; width: 190px; }
.bar .ico { font-size: 15px; width: 22px; text-align: center; }
.bar .track { flex: 1; height: 10px; background: rgba(255,255,255,.18); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: var(--green); transition: width .4s; }
.bar.warn .fill { background: var(--yellow); }
.bar.low .fill { background: var(--red); }
.bar .txt { min-width: 38px; text-align: right; font-size: 12px; opacity: .9; }

.hud-tr { position: fixed; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r)); display: flex; gap: 10px; align-items: flex-start; }
.clock-w { display: flex; align-items: center; gap: 6px; background: rgba(43,29,20,.78); color: #fff; border-radius: 999px; padding: 3px 12px 3px 3px; font-weight: 700; box-shadow: var(--shadow); cursor: pointer; }
.clock-w svg { width: 34px; height: 34px; }
.round-btn { width: 58px; height: 58px; border-radius: 50%; border: 4px solid #fff; background: var(--orange); color: #fff; font-size: 26px; box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; position: relative; transition: transform .1s; }
.round-btn:active { transform: scale(.94); }
.round-btn .badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 12px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; border: 2px solid #fff; }
/* above the full-screen joystick/camera layer (.input-zone, z-index 5), or taps never reach them */
.hud-tl, .hud-tr, .goal { z-index: 12; }

.goal { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: rgba(255, 248, 236, .95); border-radius: 16px; padding: 6px 14px 8px; box-shadow: var(--shadow); min-width: 240px; max-width: min(46vw, 420px); text-align: center; cursor: pointer; border: 3px solid #fff; }
.goal .g-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; }
.goal .g-text { font-weight: 800; font-size: 16px; line-height: 1.15; }
.goal .g-bar { height: 8px; background: #ecdcc3; border-radius: 5px; margin-top: 4px; overflow: hidden; }
.goal .g-bar div { height: 100%; background: linear-gradient(90deg, var(--green), #6cd48a); border-radius: 5px; transition: width .5s; }
/* the goal's quick button: the next step for it */
.goal { display: flex; align-items: center; gap: 10px; max-width: min(60vw, 560px); }
.goal .g-main { flex: 1; min-width: 0; }
.g-go { flex: none; border: 3px solid #fff; background: var(--green); color: #fff; font-family: var(--font); font-weight: 800; font-size: 15px; border-radius: 14px; padding: 6px 12px; box-shadow: 0 3px 0 var(--green-d); cursor: pointer; white-space: nowrap; animation: goPulse 2.4s ease-in-out infinite; }
.g-go:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-d); }
@keyframes goPulse { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.08); } 90% { transform: scale(.98); } }
@media (max-width: 900px), (max-height: 520px) { .goal { top: auto; bottom: calc(8px + var(--safe-b)); min-width: 180px; max-width: 58vw; padding: 4px 6px 6px 10px; gap: 6px; } .goal .g-text { font-size: 13px; } .g-go { font-size: 13px; padding: 4px 8px; border-radius: 12px; } .bar { width: 150px; } .portrait { width: 52px; height: 52px; } .round-btn { width: 50px; height: 50px; } }

/* quick menu */
.qmenu { position: fixed; top: calc(76px + var(--safe-t)); right: calc(12px + var(--safe-r)); display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; transform-origin: top right; transition: transform .2s, opacity .2s; z-index: 30; max-height: calc(100vh - 90px); overflow: auto; padding: 4px; }
.qmenu.closed { transform: scale(.4); opacity: 0; pointer-events: none; }
.qm-item { width: 110px; height: 84px; border-radius: 18px; border: 3px solid #fff; background: var(--cream); box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: var(--ink); gap: 2px; }
.qm-item .ico { font-size: 30px; line-height: 1; }
.qm-item img.ico { width: 40px; height: 40px; }
.qm-item:active { transform: scale(.95); }
.qm-item .dot { position: absolute; }

/* action buttons (right) */
.action-bar { position: fixed; right: calc(18px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px; z-index: 20; }
.act-btn { min-width: 76px; height: 76px; border-radius: 38px; border: 4px solid #fff; background: rgba(240, 138, 36, .95); color: #fff; font-weight: 800; font-size: 15px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; padding: 0 20px 0 16px; cursor: pointer; position: relative; touch-action: none; }
.act-btn .ico { font-size: 28px; }
.act-btn.big { min-width: 104px; height: 104px; border-radius: 52px; font-size: 18px; justify-content: center; flex-direction: column; gap: 0; padding: 0 14px; }
.act-btn.big .ico { font-size: 36px; }
.act-btn.green { background: rgba(58, 163, 91, .95); }
.act-btn.blue { background: rgba(58, 123, 213, .95); }
.act-btn.red { background: rgba(224, 69, 58, .95); }
.act-btn.purple { background: rgba(138, 90, 184, .95); }
.act-btn.yellow { background: rgba(245, 197, 66, .97); color: #5a3a10; }
.act-btn.gray { background: rgba(90, 80, 70, .9); }
.act-btn kbd { position: absolute; top: -8px; left: -8px; background: #fff; color: var(--ink); border-radius: 8px; font-size: 11px; padding: 1px 6px; font-family: var(--font); font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.act-btn.hit, .act-btn:active { transform: scale(.92); filter: brightness(1.1); }
@media (pointer: coarse) { .act-btn kbd { display: none; } }

/* floating joystick */
/* the joystick drawings sit in #ui, whose `#ui > *` would catch the touch: it must reach the input zone below */
.joy-base { position: fixed; width: 128px; height: 128px; margin: -64px 0 0 -64px; border-radius: 50%; background: rgba(255,255,255,.18); border: 3px solid rgba(255,255,255,.55); display: none; z-index: 6; pointer-events: none !important; }
.joy-base.on { display: block; }
.joy-knob { position: absolute; left: 34px; top: 34px; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.joy-hint { position: fixed; left: calc(30px + var(--safe-l)); bottom: calc(30px + var(--safe-b)); width: 110px; height: 110px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.45); display: none; place-items: center; color: rgba(255,255,255,.8); font-weight: 700; font-size: 13px; text-align: center; pointer-events: none !important; z-index: 6; }
@media (pointer: coarse) { .joy-hint { display: grid; } }

/* toasts */
.toasts { position: fixed; top: calc(84px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 60; pointer-events: none !important; }
.toast { background: rgba(43, 29, 20, .9); color: #fff; padding: 8px 18px; border-radius: 14px; font-weight: 700; font-size: 17px; box-shadow: var(--shadow); animation: toastIn .3s ease-out; display: flex; align-items: center; gap: 8px; max-width: 80vw; }
.toast.good { background: rgba(42, 124, 68, .95); }
.toast.bad { background: rgba(190, 50, 40, .95); }
.toast.gold { background: linear-gradient(90deg, #d9a92c, #f5c542); color: #4a2c05; }
.toast.out { animation: toastOut .4s forwards; }
@keyframes toastIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

/* floating label over 3D */
.world-label { position: fixed; transform: translate(-50%, -100%); pointer-events: none !important; font-weight: 800; color: #fff; font-size: 14px; text-shadow: 0 2px 3px rgba(0,0,0,.55), 0 0 2px rgba(0,0,0,.6); white-space: nowrap; z-index: 4; }
.world-label.bot { font-size: 13px; color: #fff4d6; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.world-label.friend { color: #ffd1e0; font-size: 14px; }
.card.friend h3 { margin: 0 0 2px; }
.world-label.bubble { background: #fff; color: var(--ink); text-shadow: none; padding: 4px 10px; border-radius: 12px; box-shadow: var(--shadow); font-size: 15px; }
.world-label.place { background: rgba(43,29,20,.75); padding: 3px 10px; border-radius: 10px; font-size: 14px; }
/* waypoint badge (engine/waypoint.js): over the flag, or on the screen edge pointing at it. color = the flag's */
.waypoint { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 4; pointer-events: none !important; }
.waypoint .wp-badge { position: absolute; left: -25px; top: -25px; width: 50px; height: 50px; border-radius: 50%; background: #fffdf5; border: 3px solid currentColor; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.waypoint .wp-badge svg { width: 34px; height: 34px; }
.waypoint .wp-rot { position: absolute; left: -38px; top: -38px; width: 76px; height: 76px; }
.waypoint .wp-rot i { position: absolute; left: 25px; top: -3px; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 17px solid currentColor; filter: drop-shadow(0 0 1.5px #5a3a10); }
.waypoint .wp-dist { position: absolute; top: 28px; left: 0; transform: translateX(-50%); background: rgba(43,29,20,.85); color: #fff; font-weight: 800; font-size: 13px; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.waypoint.on-screen .wp-rot { opacity: .9; }
.waypoint.quiet { opacity: .85; }
.waypoint.quiet .wp-badge { transform: scale(.85); }

/* ------------------------------------------------------------ panels */
.overlay { position: fixed; inset: 0; background: rgba(30, 18, 8, .45); z-index: 50; display: grid; place-items: center; padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l)); animation: fadeIn .2s; backdrop-filter: blur(2px); }
@keyframes fadeIn { from { opacity: 0; } }
.panel { background: var(--cream); border-radius: 26px; box-shadow: 0 16px 40px rgba(0,0,0,.4); border: 5px solid #fff; width: min(920px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; animation: popIn .25s cubic-bezier(.2,1.4,.5,1); }
.panel.wide { width: min(1100px, 100%); }
.panel.narrow { width: min(560px, 100%); }
.panel.full { width: 100%; height: 100%; }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px 8px 18px; background: linear-gradient(180deg, #8a5a36, #6b4226); color: #fff; }
.panel-head h2 { margin: 0; font-size: 26px; flex: 1; text-shadow: 0 2px 0 rgba(0,0,0,.25); display: flex; align-items: center; gap: 10px; }
.panel-head h2 img { width: 36px; height: 36px; }
.panel-head .x { width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fff; background: var(--red); color: #fff; font-size: 24px; font-weight: 800; cursor: pointer; display: grid; place-items: center; }
.panel-head .extra { display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 14px 18px 18px; overflow: auto; flex: 1; touch-action: pan-y; }
.panel-tabs { display: flex; gap: 6px; padding: 8px 14px 0; background: var(--cream-2); flex-wrap: wrap; }
.tab { border: none; background: #e9d6b6; padding: 8px 16px; border-radius: 14px 14px 0 0; font-weight: 800; font-size: 16px; color: var(--ink-soft); cursor: pointer; }
.tab.on { background: var(--cream); color: var(--ink); }

.btn { border: none; border-radius: 16px; padding: 10px 20px; font-weight: 800; font-size: 18px; cursor: pointer; color: #fff; background: var(--orange); box-shadow: 0 4px 0 var(--orange-d); transition: transform .08s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; min-height: 50px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--orange-d); }
.btn.green { background: var(--green); box-shadow: 0 4px 0 var(--green-d); }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 #2a5ca8; }
.btn.red { background: var(--red); box-shadow: 0 4px 0 #a8322a; }
.btn.gray { background: #b5a28c; box-shadow: 0 4px 0 #8c7a66; }
.btn.purple { background: var(--purple); box-shadow: 0 4px 0 #6a3f94; }
.btn.small { padding: 6px 14px; font-size: 15px; min-height: 38px; border-radius: 12px; }
.btn[disabled], .btn.off { filter: grayscale(.7); opacity: .6; cursor: not-allowed; }
.price { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; }
.price::before { content: ''; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b0, #e8b53a 60%, #b8871a); display: inline-block; box-shadow: inset 0 0 0 2px #c99a2a; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.card { background: var(--paper); border-radius: 18px; padding: 12px; box-shadow: 0 3px 0 #e6d3b3, 0 4px 12px rgba(80,50,20,.08); display: flex; flex-direction: column; gap: 6px; position: relative; border: 2px solid #f0e2c8; }
.card.sel { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(240,138,36,.35); }
.card img.icon { width: 96px; height: 96px; align-self: center; object-fit: contain; }
.card h3 { margin: 0; font-size: 19px; }
.card .sub { color: var(--ink-soft); font-size: 14px; line-height: 1.2; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .owned { position: absolute; top: 8px; right: 8px; background: var(--green); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.tag { display: inline-block; background: #efe0c5; border-radius: 8px; padding: 1px 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.tag.good { background: #d6f0dc; color: var(--green-d); }
.tag.bad { background: #fadad6; color: #a8322a; }
.hint { background: #fff3cf; border: 2px dashed #e7c46a; border-radius: 14px; padding: 8px 12px; font-size: 15px; color: #6a4b12; }
.muted { color: var(--ink-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stars { color: #f5b301; letter-spacing: 1px; font-size: 16px; }
.stars .off { color: #d9c9ad; }
.statbar { display: grid; grid-template-columns: 110px 1fr 56px; gap: 8px; align-items: center; font-weight: 700; font-size: 15px; }
.statbar .track { height: 12px; background: #ecdcc3; border-radius: 6px; overflow: hidden; }
.statbar .fill { height: 100%; background: var(--blue); border-radius: 6px; }
.statbar .fill.xp { background: linear-gradient(90deg, #6cd48a, var(--green)); }

/* ------------------------------------------------------------ learning tasks (shop/library/clock) */
.task-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 16px; min-height: 360px; }
@media (max-width: 760px) { .task-wrap { grid-template-columns: 1fr; } }
.task-scene { background: var(--paper); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; border: 2px solid #f0e2c8; }
.task-q { font-size: 26px; font-weight: 800; text-align: center; display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
.speak { width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; background: var(--blue); color: #fff; font-size: 26px; cursor: pointer; box-shadow: var(--shadow); flex: none; }
.items-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 42px; min-height: 60px; align-items: center; max-width: 560px; }
.items-row .op { font-size: 44px; font-weight: 800; color: var(--ink-soft); margin: 0 6px; }
.items-row img { width: 54px; height: 54px; }
.answers { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.ans { min-width: 84px; height: 84px; border-radius: 22px; border: 4px solid #fff; background: var(--orange); color: #fff; font-size: 38px; font-weight: 800; cursor: pointer; box-shadow: 0 5px 0 var(--orange-d); padding: 0 14px; }
.ans:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--orange-d); }
.ans.right { background: var(--green); box-shadow: 0 5px 0 var(--green-d); animation: pop .4s; }
.ans.wrong { background: var(--red); box-shadow: 0 5px 0 #a8322a; animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.15); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.numpad { display: grid; grid-template-columns: repeat(5, 64px); gap: 8px; justify-content: center; }
.numpad button { height: 58px; border-radius: 16px; border: 3px solid #fff; background: #fff; box-shadow: 0 4px 0 #e0cba8; font-size: 28px; font-weight: 800; color: var(--ink); cursor: pointer; }
.numpad button.ok { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d); }
.numpad button.del { background: #e9d6b6; }
.num-display { font-size: 44px; font-weight: 800; min-width: 150px; min-height: 64px; text-align: center; background: #fff; border-radius: 16px; border: 3px dashed #e0cba8; padding: 0 16px; }
.num-display.reveal { background: #e4f5e8; border: 3px solid var(--green); color: var(--green-d); }
.letter-tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { width: 64px; height: 64px; border-radius: 14px; background: #fff; border: 3px solid #e7cf9f; box-shadow: 0 5px 0 #d9bd86; font-size: 36px; font-weight: 800; cursor: pointer; display: grid; place-items: center; color: var(--ink); text-transform: uppercase; }
.tile.used { opacity: .25; pointer-events: none; }
.tile.slot { background: #fbf2de; border-style: dashed; box-shadow: none; cursor: default; }
.tile.slot.filled { background: #fff; border-style: solid; cursor: pointer; }
.tile.slot.gap { background: #fff3cf; border-color: var(--orange); }
.tile.hint { color: #b9a78d; }
.tile.slot.fixed, .tile.right { background: #e4f5e8; border-color: var(--green); border-style: solid; color: var(--green-d); }
.tile.reveal { background: #fff3cf; border-color: var(--orange); color: var(--orange); }
.tile.wrong { border-color: var(--red); animation: shake .4s; }
.letter-tiles.right .tile { background: #e4f5e8; border-color: var(--green); color: var(--green-d); animation: pop .4s; }
.letter-tiles.wrong { animation: shake .4s; }
.letter-tiles.long .tile { width: 52px; height: 52px; font-size: 30px; }
.letter-tiles.keyboard { max-width: 560px; gap: 6px; }
.letter-tiles.keyboard .tile { width: 50px; height: 50px; font-size: 26px; }
.letter-tiles.keyboard .tile.del { width: 106px; }
.side-info { display: flex; flex-direction: column; gap: 10px; }
.side-info .box { background: var(--paper); border-radius: 16px; padding: 10px 12px; border: 2px solid #f0e2c8; }
.side-info .big { font-size: 28px; font-weight: 800; }
.trin-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.trin-dots span { width: 22px; height: 22px; border-radius: 50%; background: #e9d6b6; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.trin-dots span.on { background: var(--green); }
.trin-dots span.cur { background: var(--orange); transform: scale(1.2); }
.streak { display: flex; gap: 4px; }
.streak i { width: 16px; height: 16px; border-radius: 50%; background: #e9d6b6; }
.streak i.on { background: var(--green); }
.streak i.miss { background: var(--red); }
.feedback .explain { font-size: 18px; color: var(--ink); background: #fff3cf; border: 2px solid var(--orange); border-radius: 14px; padding: 8px 12px; margin: 6px auto 8px; max-width: 520px; text-align: center; }
/* shop: a box with places in rows of five (ten-frame) */
.tray { display: grid; gap: 4px; padding: 6px; background: #c8955a; border-radius: 12px; box-shadow: inset 0 0 0 3px #a8743e; }
.tray .cell { width: 44px; height: 44px; border-radius: 8px; background: #fff6e4; display: grid; place-items: center; font-size: 30px; line-height: 1; position: relative; }
.tray .cell img { width: 36px; height: 36px; }
.tray .cell.empty { background: rgba(255, 246, 228, .3); border: 2px dashed #fff6e4; }
.tray .cell.gone > * { opacity: .25; }
.tray .cell.gone::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-size: 30px; font-weight: 800; }
.items-row.many .tray .cell { width: 30px; height: 30px; font-size: 20px; }
.items-row.many .tray .cell img { width: 24px; height: 24px; }
.coin-fly { position: fixed; z-index: 90; font-size: 28px; pointer-events: none; animation: coinFly .9s ease-in forwards; }
@keyframes coinFly { to { transform: translate(var(--dx), var(--dy)) scale(.5); opacity: .2; } }
.feedback { font-size: 22px; font-weight: 800; min-height: 32px; text-align: center; }
.feedback.good { color: var(--green-d); }
.feedback.bad { color: var(--red); }

/* analog clock (clockmaker) */
.aclock { width: 240px; height: 240px; touch-action: none; }
.aclock .face { fill: #fffdf5; stroke: #6b4226; stroke-width: 8; }
.aclock .hand-h { stroke: #3a2a1f; stroke-width: 9; stroke-linecap: round; }
.aclock .hand-m { stroke: #2f6fb5; stroke-width: 6; stroke-linecap: round; }
.aclock .hand-h.drag, .aclock .hand-m.drag { stroke: var(--orange); }
.aclock.reveal .hand-h, .aclock.reveal .hand-m { stroke: var(--green); }
.aclock text { font-weight: 800; font-size: 20px; fill: #3a2a1f; text-anchor: middle; dominant-baseline: central; font-family: var(--font); }
.aclock text.min { font-size: 16px; fill: #2f6fb5; }
.ans.digi { font-family: 'Courier New', monospace; font-size: 30px; letter-spacing: 2px; background: #1c1c1c; color: #7dff8a; box-shadow: 0 5px 0 #000; }
.ans.digi.right { background: var(--green); color: #fff; }
/* clock answers that are only text: a 🔊 on each, and the one being read lights up */
.ans.has-say { position: relative; }
.ans-say { position: absolute; top: -12px; right: -12px; width: 38px; height: 38px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; font-size: 17px; display: grid; place-items: center; box-shadow: var(--shadow); }
.ans.saying { outline: 5px solid var(--yellow); outline-offset: 2px; transform: scale(1.06); }
.feedback .explain .speak.small { width: 38px; height: 38px; font-size: 17px; float: left; margin: 0 8px 2px 0; }
.time-jump { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.time-jump .dclock { font-size: 32px; }
.time-jump .jump { font-size: 20px; font-weight: 800; background: #fff3cf; border: 2px solid var(--orange); border-radius: 999px; padding: 4px 14px; }
.time-jump .jump::before, .time-jump .jump::after { content: ' ➜ '; color: var(--orange); }
.aclock .knob { fill: var(--orange); cursor: grab; }
.dclock { font-size: 52px; font-weight: 800; background: #1c1c1c; color: #7dff8a; padding: 6px 18px; border-radius: 12px; letter-spacing: 3px; font-family: 'Courier New', monospace; text-shadow: 0 0 8px rgba(125,255,138,.6); }

/* ------------------------------------------------------------ stable & care */
.stable-view { position: fixed; inset: 0; z-index: 40; }
.stable-ui { position: fixed; inset: 0; z-index: 41; pointer-events: none !important; }
.stable-ui > * { pointer-events: auto; }
.door-sign { position: fixed; transform: translate(-50%, -100%); width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; font-size: 28px; border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer; }
.door-sign.red { background: var(--red); animation: wiggle 1.2s infinite; }
.door-sign.yellow { background: var(--yellow); }
.door-sign .n { position: absolute; top: -9px; right: -9px; background: #fff; color: var(--ink); font-size: 13px; font-weight: 800; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
@keyframes wiggle { 0%, 60%, 100% { transform: translate(-50%, -100%) rotate(0); } 70% { transform: translate(-50%, -100%) rotate(-10deg); } 85% { transform: translate(-50%, -100%) rotate(10deg); } }
.door-name { position: fixed; transform: translate(-50%, 0); background: #fff; border-radius: 10px; padding: 3px 12px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow); cursor: pointer; white-space: nowrap; }
.tools { position: fixed; right: calc(20px + var(--safe-r)); top: 50%; transform: translateY(-50%); background: linear-gradient(90deg, #9a6b43, #8a5a36); border-radius: 18px; padding: 12px; display: grid; grid-template-columns: repeat(2, 86px); gap: 10px; border: 4px solid #6b4226; box-shadow: var(--shadow); }
.tool { width: 86px; height: 92px; border-radius: 16px; background: rgba(255,248,236,.95); border: 3px solid #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; font-size: 12px; font-weight: 800; }
.tool img { width: 56px; height: 56px; object-fit: contain; }
.tool .mark { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; }
.tool.need .mark { background: var(--red); }
.tool.need img { animation: tilt 1.1s infinite; }
.tool.soon .mark { background: var(--yellow); }
.tool.done .mark { background: var(--green); }
.tool.done .mark::after { content: '✓'; color: #fff; font-size: 13px; position: absolute; inset: 0; display: grid; place-items: center; }
.tool.off { opacity: .45; }
.tool .cost { font-size: 11px; color: var(--ink-soft); }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.nameplate { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); background: var(--cream); border: 4px solid #fff; border-radius: 18px; padding: 8px 18px; box-shadow: var(--shadow); min-width: 280px; text-align: center; }
.nameplate h3 { margin: 0; font-size: 24px; }
.nameplate .mood { display: flex; align-items: center; gap: 8px; }
.back-btn { position: fixed; bottom: calc(18px + var(--safe-b)); left: calc(14px + var(--safe-l)); }
body.in-stable .world-label, body.in-stable .chat, body.in-stable .joy-hint, body.in-stable .waypoint { display: none !important; }

/* minigames */
.mini { position: fixed; inset: 0; z-index: 70; background: rgba(30,18,8,.55); display: grid; place-items: center; }
.mini-card { background: var(--cream); border: 5px solid #fff; border-radius: 26px; padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 8px; align-items: center; max-width: 96vw; max-height: 96vh; }
.mini-card canvas { border-radius: 16px; touch-action: none; max-width: 100%; max-height: 72vh; cursor: none; }
.mini-top { display: flex; align-items: center; gap: 12px; width: 100%; }
.mini-top h3 { margin: 0; font-size: 22px; flex: 1; }
.progress { flex: 1; height: 18px; background: #ecdcc3; border-radius: 10px; overflow: hidden; min-width: 160px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--green), #6cd48a); transition: width .15s; }

/* discipline HUD */
.disc-hud { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 30; }
.disc-hud .pill { font-size: 20px; padding: 4px 16px; }
.disc-hint { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); width: max-content; max-width: min(520px, 56vw); text-align: center; font-size: 18px; font-weight: 700; z-index: 30; pointer-events: none !important; box-shadow: var(--shadow); }
.grade { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%); font-size: 64px; font-weight: 800; color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 20px rgba(0,0,0,.3); pointer-events: none !important; z-index: 35; animation: gradeIn .8s forwards; white-space: nowrap; }
.grade.perfect { color: #ffe066; }
.grade.good { color: #a6f5b5; }
.grade.bad { color: #ff9b8f; }
@keyframes gradeIn { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -70%) scale(1); opacity: 0; } }
.pulse-ring { position: fixed; border-radius: 50%; border: 6px solid #fff; pointer-events: none !important; z-index: 25; box-shadow: 0 0 10px rgba(0,0,0,.3); }
.dress-lane { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); width: min(760px, 70vw); height: 92px; background: rgba(43, 29, 20, .55); border-radius: 46px; overflow: hidden; z-index: 25; border: 3px solid rgba(255,255,255,.7); }
.dress-lane .zone { position: absolute; left: 60px; top: 6px; width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; box-shadow: 0 0 14px rgba(255,255,255,.6); }
.dress-lane .icon { position: absolute; top: 10px; width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; border: 3px solid #fff; color: #fff; font-weight: 800; }
.dress-btns { position: fixed; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: grid; grid-template-columns: repeat(2, 92px); gap: 10px; z-index: 26; }
.dress-btns button { height: 84px; border-radius: 22px; border: 4px solid #fff; color: #fff; font-weight: 800; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); cursor: pointer; }
.dress-btns button .i { font-size: 30px; line-height: 1; }
.dress-btns button kbd { font-size: 10px; background: rgba(255,255,255,.3); border-radius: 5px; padding: 0 4px; }

.result-medal { font-size: 110px; line-height: 1; text-align: center; animation: pop .6s; }
.leader { width: 100%; border-collapse: collapse; }
.leader td, .leader th { padding: 6px 8px; text-align: left; border-bottom: 1px solid #efe0c5; font-size: 16px; }
.leader tr.me td { background: #fff3cf; font-weight: 800; }

/* map */
.map-wrap { position: relative; width: 100%; aspect-ratio: 1; max-height: 70vh; margin: 0 auto; }
.map-wrap canvas { width: 100%; height: 100%; border-radius: 16px; }

/* chat */
.chat { position: fixed; left: calc(12px + var(--safe-l)); bottom: calc(150px + var(--safe-b)); width: 280px; display: flex; flex-direction: column; gap: 4px; pointer-events: none !important; z-index: 8; }
.chat .msg { background: rgba(43,29,20,.65); color: #fff; padding: 3px 10px; border-radius: 10px; font-size: 14px; width: fit-content; animation: toastIn .3s; }
.chat .msg b { color: #ffd98a; }
.chat-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-pick button { font-size: 18px; border: none; background: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: 0 3px 0 #e0cba8; cursor: pointer; font-family: var(--font); font-weight: 700; }

/* creator */
.creator { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .creator { grid-template-columns: 1fr; } }
.creator .preview { background: radial-gradient(circle at 50% 40%, #fff, #f2e2c4); border-radius: 20px; min-height: 340px; position: relative; overflow: hidden; }
@media (max-height: 520px) { .creator { grid-template-columns: 38% 1fr; } .creator .preview { position: sticky; top: 0; } }
.creator .preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 4px var(--orange); }
.opt { border: 3px solid #fff; background: #fff; border-radius: 14px; padding: 8px 12px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #e0cba8; font-size: 15px; }
.opt.on { background: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--orange-d); }
input.name { font-family: var(--font); font-size: 22px; font-weight: 800; padding: 8px 14px; border-radius: 14px; border: 3px solid #e0cba8; width: 100%; background: #fff; color: var(--ink); }

/* farm build: the help text and the build button at the bottom, cancel as a round ✕ in the top corner */
.build-bar { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 14px; background: rgba(255,248,236,.95); padding: 10px 10px 10px 16px; border-radius: 20px; box-shadow: var(--shadow); z-index: 30; align-items: center; border: 3px solid #fff; width: max-content; max-width: calc(100vw - 150px); }
.build-bar .b-info { font-weight: 800; font-size: 17px; line-height: 1.2; }
.build-bar .b-ok { flex: none; font-size: 20px; }
.build-bar .b-ok.ready { animation: goPulse 2s ease-in-out infinite; }
.build-cancel { position: fixed; top: calc(12px + var(--safe-t)); right: calc(14px + var(--safe-r)); z-index: 31; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; padding: 0; cursor: pointer; font-family: var(--font); }
.build-cancel .x { width: 56px; height: 56px; border-radius: 50%; border: 4px solid #fff; background: var(--red); color: #fff; font-size: 26px; font-weight: 800; display: grid; place-items: center; box-shadow: var(--shadow); }
.build-cancel .lbl { color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.build-cancel:active .x { transform: scale(.92); }
/* giving up a riding job: small, under the menu button, away from the riding buttons */
.job-quit { position: fixed; top: calc(78px + var(--safe-t)); right: calc(16px + var(--safe-r)); z-index: 12; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; padding: 0; cursor: pointer; font-family: var(--font); }
.job-quit .x { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; background: var(--red); color: #fff; font-size: 20px; font-weight: 800; display: grid; place-items: center; box-shadow: var(--shadow); }
.job-quit .lbl { color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; }
.job-quit:active .x { transform: scale(.92); }

/* shop: buy or earn */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.choice { border: 4px solid #fff; border-radius: 22px; padding: 18px 12px; color: #fff; font-family: var(--font); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 5px 0 rgba(0,0,0,.2), var(--shadow); }
.choice:active { transform: translateY(3px); }
.choice.blue { background: var(--blue); }
.choice.green { background: var(--green); }
.choice .c-ico { font-size: 56px; line-height: 1.1; }
.choice .c-title { font-size: 26px; font-weight: 800; }
.choice .c-sub { font-size: 15px; opacity: .95; text-align: center; }
/* earn money: the four places */
.grid.earn .card { cursor: pointer; }
.grid.earn .card:active { transform: scale(.98); }
.grid.earn .e-ico { font-size: 40px; }
.grid.earn .card.tired { opacity: .75; }
/* a sign for children who don't read yet: ABC at the library, 2+2=4 at the shop (earn cards, the shop's choice, labels in the valley), ⏰ at the clockmaker (label only: its card already shows a clock) */
.e-badge { flex: none; align-self: flex-start; background: var(--purple); color: #fff; font-weight: 900; font-size: 22px; letter-spacing: 1px; padding: 3px 12px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0,0,0,.18); white-space: nowrap; transform: rotate(4deg); }
.e-badge.shop { background: var(--orange); }
.grid.earn .e-badge { position: absolute; top: 14px; right: 12px; }
.choice { position: relative; }
.choice .e-badge { position: absolute; top: -12px; right: -8px; }
.pl-badge { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 7px; background: var(--purple); color: #fff; font-weight: 900; text-shadow: none; }
.pl-badge.shop { background: var(--orange); }
.pl-badge.clock { background: var(--blue); }
.intro-card { max-width: 560px; }
.big-emoji { font-size: 64px; text-align: center; line-height: 1.1; }
.center { text-align: center; }
.fade-black { position: fixed; inset: 0; background: #000; z-index: 95; pointer-events: none !important; opacity: 0; transition: opacity .35s; }
.fade-black.on { opacity: 1; }

/* ------------------------------------------------------------ phones in landscape: little height */
/* slim panel chrome, one row of tabs, tasks beside their info column, a flat quick menu */
@media (max-height: 520px) {
  .overlay { padding: calc(4px + var(--safe-t)) calc(6px + var(--safe-r)) calc(4px + var(--safe-b)) calc(6px + var(--safe-l)); }
  .panel { border-width: 3px; border-radius: 16px; }
  .panel-head { padding: 3px 6px 3px 12px; gap: 8px; }
  .panel-head h2 { font-size: 19px; gap: 6px; }
  .panel-head h2 img { width: 26px; height: 26px; }
  .panel-head .x { width: 36px; height: 36px; font-size: 18px; border-width: 2px; }
  .panel-tabs { flex-wrap: nowrap; overflow-x: auto; padding: 4px 8px 0; scrollbar-width: none; touch-action: pan-x; }
  .tab { padding: 4px 12px; font-size: 14px; white-space: nowrap; flex: none; }
  .panel-body { padding: 8px 10px 10px; }
  .btn { min-height: 42px; padding: 6px 14px; font-size: 16px; }
  .grid { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card { padding: 8px; gap: 4px; }
  .card img.icon { width: 64px; height: 64px; }
  .card h3 { font-size: 16px; }
  .hint { padding: 5px 10px; font-size: 13px; }
  .creator .preview { min-height: 0; height: 58vh; }
  .act-btn.big { min-width: 88px; height: 88px; }
  .task-wrap { grid-template-columns: 1fr 170px; gap: 8px; min-height: 0; }
  .task-scene { padding: 8px; gap: 6px; }
  .task-q { font-size: 19px; gap: 6px; }
  .speak { width: 40px; height: 40px; font-size: 19px; }
  .items-row { font-size: 28px; min-height: 36px; gap: 4px; }
  .items-row .op { font-size: 28px; }
  .items-row img { width: 36px; height: 36px; }
  .answers { gap: 8px; }
  .ans { min-width: 62px; height: 58px; font-size: 28px; border-radius: 16px; border-width: 3px; }
  .numpad { grid-template-columns: repeat(5, 50px); gap: 5px; }
  .numpad button { height: 40px; font-size: 21px; border-radius: 12px; }
  .num-display { font-size: 30px; min-height: 44px; min-width: 110px; }
  .tile { width: 46px; height: 46px; font-size: 26px; }
  .letter-tiles.long .tile { width: 38px; height: 38px; font-size: 21px; }
  .letter-tiles.keyboard { max-width: none; gap: 4px; }
  .letter-tiles.keyboard .tile { width: 34px; height: 34px; font-size: 19px; border-width: 2px; border-radius: 9px; box-shadow: 0 3px 0 #d9bd86; }
  .letter-tiles.keyboard .tile.del { width: 72px; }
  .task-scene .big-emoji { font-size: 40px; }
  .aclock { width: 150px; height: 150px; }
  .tray { padding: 4px; gap: 3px; }
  .tray .cell { width: 26px; height: 26px; font-size: 18px; }
  .tray .cell.gone::after { font-size: 18px; }
  .tray .cell img { width: 22px; height: 22px; }
  .items-row.many .tray .cell { width: 20px; height: 20px; font-size: 14px; }
  .items-row.many .tray .cell img { width: 16px; height: 16px; }
  .feedback .explain { font-size: 14px; padding: 4px 8px; margin: 3px auto 4px; }
  .ans.digi { font-size: 20px; }
  .ans-say { width: 30px; height: 30px; font-size: 14px; top: -9px; right: -9px; }
  .time-jump .dclock { font-size: 22px; }
  .time-jump .jump { font-size: 15px; padding: 2px 8px; }
  .dclock { font-size: 32px; padding: 2px 12px; }
  .feedback { font-size: 17px; min-height: 22px; }
  .side-info { gap: 6px; font-size: 13px; }
  .side-info .box { padding: 6px 8px; }
  .side-info .big { font-size: 20px; }
  .qmenu { grid-template-columns: repeat(5, 1fr); top: calc(62px + var(--safe-t)); gap: 6px; }
  .qm-item { width: 88px; height: 58px; font-size: 11px; border-radius: 14px; }
  .qm-item .ico { font-size: 22px; }
  .toast { font-size: 14px; padding: 5px 12px; }
  .result-medal { font-size: 64px; }
  .leader td, .leader th { padding: 3px 6px; font-size: 14px; }
  /* stable: care tools as a small block top right, a slimmer name plate below the horse */
  .tools { top: calc(6px + var(--safe-t)); right: calc(8px + var(--safe-r)); transform: none; grid-template-columns: repeat(4, 66px); gap: 6px; padding: 6px; border-width: 3px; border-radius: 14px; }
  .tool { width: 66px; height: 62px; font-size: 10px; border-radius: 12px; border-width: 2px; }
  .tool img { width: 32px; height: 32px; }
  .tool > span:first-child:not(.cost):not(.mark) { font-size: 26px !important; }
  .tool .cost { font-size: 9px; }
  .tool .mark { width: 16px; height: 16px; border-width: 2px; top: -4px; right: -4px; }
  .nameplate { bottom: calc(6px + var(--safe-b)); padding: 4px 12px 6px; min-width: 240px; border-width: 3px; font-size: 14px; }
  .nameplate h3 { font-size: 18px; }
  .nameplate .bar { width: 150px !important; }
  .back-btn { bottom: calc(8px + var(--safe-b)); }
  .build-bar { padding: 6px 6px 6px 12px; gap: 10px; border-radius: 16px; bottom: calc(6px + var(--safe-b)); }
  .build-bar .b-info { font-size: 14px; }
  .build-bar .b-ok { font-size: 17px; }
  .build-cancel .x { width: 46px; height: 46px; font-size: 21px; border-width: 3px; }
  .build-cancel { top: calc(6px + var(--safe-t)); }
  .job-quit { top: calc(62px + var(--safe-t)); right: calc(14px + var(--safe-r)); }
  .job-quit .x { width: 38px; height: 38px; font-size: 17px; }
  .choices { gap: 10px; margin-top: 6px; }
  .choice { padding: 8px; }
  .choice .c-ico { font-size: 38px; }
  .choice .c-title { font-size: 21px; }
  .choice .c-sub { font-size: 13px; }
  .grid.earn .e-ico { font-size: 30px; }
  .e-badge { font-size: 17px; padding: 1px 9px; }
}
