:root {
  --ink: #2b2118;
  --paper: #fbf3e4;
  --panel: rgba(43, 33, 24, 0.72);
  --panel-solid: #3a2c20;
  --line: rgba(255, 236, 205, 0.18);
  --gold: #f2b35b;
  --ember: #e9783a;
  --text: #fff6e8;
  --muted: #d8c7ad;
  --good: #8fd16a;
  --bad: #ef6b5b;
  --font: "Avenir Next", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2118; color: var(--text); font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: 0; color: inherit; }

.primary { background: linear-gradient(180deg, #f6be68, #e48a3c); color: #3a1f0c; font-weight: 800; letter-spacing: .02em; border-radius: 999px; padding: 12px 26px; font-size: 16px; box-shadow: 0 6px 18px rgba(120, 50, 10, .35), inset 0 1px 0 rgba(255, 255, 255, .5); transition: transform .12s, filter .12s; }
.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.primary:active { transform: translateY(1px); }
.primary:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }
.primary.big { font-size: 20px; padding: 15px 52px; }
.ghost-btn { background: rgba(255, 246, 232, .12); border: 1px solid rgba(255, 246, 232, .35); border-radius: 999px; padding: 11px 20px; font-size: 15px; font-weight: 700; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.ghost-btn:hover { background: rgba(255, 246, 232, .22); }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; background: radial-gradient(ellipse at center, rgba(40, 25, 12, 0) 30%, rgba(40, 25, 12, .45) 100%), linear-gradient(180deg, rgba(40, 25, 12, .0) 40%, rgba(40, 25, 12, .55)); transition: opacity .9s; z-index: 20; padding: 24px; }
#title.out { opacity: 0; pointer-events: none; }
.title-inner { max-width: 640px; }
.kicker { text-transform: uppercase; letter-spacing: .32em; font-size: 12px; font-weight: 700; color: #ffe2b8; opacity: .9; text-shadow: 0 1px 8px rgba(60, 30, 10, .6); }
#title h1 { font-family: var(--serif); font-size: clamp(54px, 11vw, 112px); line-height: .95; margin: 12px 0 10px; font-weight: 700; color: #fff7ea; text-shadow: 0 4px 30px rgba(80, 35, 5, .55), 0 2px 0 rgba(120, 60, 20, .5); letter-spacing: -.01em; }
#title h1 em { font-style: italic; font-weight: 400; font-size: .6em; color: #ffd9a3; vertical-align: .18em; padding: 0 .08em; }
.sub { font-size: clamp(15px, 2.4vw, 19px); color: #fff0db; text-shadow: 0 1px 10px rgba(60, 30, 10, .8); margin: 0 0 30px; }
.btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.controls-hint { margin-top: 26px; font-size: 13px; color: #fbe9d0; opacity: .85; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #2b2118; font-family: var(--serif); font-size: 22px; color: #e9d3b0; z-index: 50; transition: opacity .6s; }
#loading.out { opacity: 0; pointer-events: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#res { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); display: flex; gap: 8px; flex-wrap: wrap; max-width: 60vw; }
.pill { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 6px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 4px 14px rgba(30, 15, 5, .25); transition: transform .2s; }
.pill b { font-size: 18px; min-width: 22px; font-variant-numeric: tabular-nums; }
.pill span { font-size: 12px; color: var(--muted); font-weight: 600; }
.pill.bump { transform: scale(1.12); }
.pill.fresh { animation: fresh 1.5s; }
@keyframes fresh { 0% { transform: scale(.4); box-shadow: 0 0 0 0 rgba(242, 179, 91, .9); } 30% { transform: scale(1.18); } 100% { transform: none; box-shadow: 0 0 0 16px rgba(242, 179, 91, 0); } }
.pill.warn { border-color: rgba(239, 107, 91, .8); animation: warn 1.4s infinite; }
.pill.warn b { color: #ffb4a8; }
@keyframes warn { 50% { background: rgba(120, 30, 20, .75); } }
.ico { width: 30px; height: 30px; border-radius: 50%; display: inline-block; background: #fbf3e4 center/20px no-repeat; flex: none; }
.ico.wood { background-color: #e7c9a0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='9' width='17' height='7' rx='3.5' fill='%237a5536'/%3E%3Ccircle cx='19' cy='12.5' r='3.5' fill='%23e3c08c' stroke='%237a5536' stroke-width='1.2'/%3E%3Ccircle cx='19' cy='12.5' r='1.3' fill='none' stroke='%23a07a4a' stroke-width='.8'/%3E%3Crect x='5' y='4' width='13' height='5.5' rx='2.7' fill='%236b4a32'/%3E%3C/svg%3E"); }
.ico.stone { background-color: #d9d6cf; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18l3-8 6-4 6 3 3 9z' fill='%238d8f93'/%3E%3Cpath d='M6 10l6-4 6 3-5 3z' fill='%23b5b6b8'/%3E%3C/svg%3E"); }
.ico.food { background-color: #f3d0cf; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3c2 1 3 3 2 5' stroke='%234b8a3f' stroke-width='2' fill='none'/%3E%3Ccircle cx='8' cy='14' r='4' fill='%23d23a44'/%3E%3Ccircle cx='15.5' cy='13' r='4' fill='%23c22f3a'/%3E%3Ccircle cx='12' cy='18' r='3.6' fill='%23e04650'/%3E%3C/svg%3E"); }
.ico.pop { background-color: #f1d6b5; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7' r='4' fill='%23a8724f'/%3E%3Cpath d='M4 21c0-5 3.5-8 8-8s8 3 8 8z' fill='%238a6a48'/%3E%3C/svg%3E"); }

.ico.copper { background-color: #cfe6d8; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18l3-8 6-4 6 3 3 9z' fill='%238f8579'/%3E%3Cpath d='M7 12l3-2 1 3-3 2zM13 9l3 1-1 3-2-1zM12 15l3 0 1 2-3 1z' fill='%233fae86'/%3E%3Cpath d='M16 14l2 1-1 2z' fill='%23d9783a'/%3E%3C/svg%3E"); }
.ico.tin { background-color: #dfe2e6; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18l3-8 6-4 6 3 3 9z' fill='%235f5c5a'/%3E%3Cpath d='M8 11l2-1 1 2-2 1zM14 10l2 1-1 2zM11 15l2-1 1 2-2 1z' fill='%23f2f5f7'/%3E%3C/svg%3E"); }
.ico.ironore { background-color: #efd2c4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18l3-8 6-4 6 3 3 9z' fill='%237a4a3a'/%3E%3Cpath d='M6 10l6-4 6 3-4 3-3-1z' fill='%23b5502c'/%3E%3Cpath d='M9 15l4-1 2 3-4 1z' fill='%23d27a44'/%3E%3C/svg%3E"); }
.ico.bronze { background-color: #f3dcb4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 16l3-6h12l3 6z' fill='%23a8742e'/%3E%3Cpath d='M6 10h12l-2 3H8z' fill='%23e0ac5a'/%3E%3Cpath d='M3 16h18v2H3z' fill='%238a5e24'/%3E%3C/svg%3E"); }
.ico.iron { background-color: #dde0e4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 16l3-6h12l3 6z' fill='%235a5e66'/%3E%3Cpath d='M6 10h12l-2 3H8z' fill='%239aa0a8'/%3E%3Cpath d='M3 16h18v2H3z' fill='%23404349'/%3E%3C/svg%3E"); }
.ico.charcoal { background-color: #d6cfc8; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17l3-5 5 1 2 5z' fill='%23302826'/%3E%3Cpath d='M10 13l4-5 6 3 1 6-7 1z' fill='%23463c38'/%3E%3Cpath d='M14 8l6 3-3 2z' fill='%23675a54'/%3E%3Ccircle cx='8' cy='15' r='1' fill='%23ff8a3a'/%3E%3C/svg%3E"); }

#goal { cursor: pointer; position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(64px, calc(env(safe-area-inset-top) + 64px)); width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 13px 15px 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(30, 15, 5, .25); transition: transform .35s, opacity .35s; }
#goal.flash { animation: goalflash .9s; }
@keyframes goalflash { 0% { box-shadow: 0 0 0 0 rgba(242, 179, 91, .9); } 100% { box-shadow: 0 0 0 18px rgba(242, 179, 91, 0); } }
.goal-kicker { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
.goal-title { font-family: var(--serif); font-size: 20px; margin: 3px 0 9px; font-weight: 700; }
.goal-bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; }
#goal-fill { height: 100%; width: 0; background: linear-gradient(90deg, #f6be68, #e9783a); border-radius: 99px; transition: width .4s; }
.goal-hint { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.35; }

#corner { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); display: flex; gap: 8px; }
.round { width: 42px; height: 42px; border-radius: 50%; background: var(--panel) center/22px no-repeat; border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#btn-mute { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff6e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z' fill='%23fff6e8'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E"); }
#btn-mute.off { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff6e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z' fill='%23fff6e8'/%3E%3Cpath d='M17 9l5 6M22 9l-5 6'/%3E%3C/svg%3E"); }

#buildbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column-reverse; align-items: center; gap: 10px; }
.build-toggle { display: flex; align-items: center; gap: 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 11px 24px 11px 16px; font-weight: 800; font-size: 16px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 18px rgba(30, 15, 5, .3); }
.build-toggle.open { background: var(--panel-solid); }
.build-toggle.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242, 179, 91, .85); } 70% { box-shadow: 0 0 0 14px rgba(242, 179, 91, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 179, 91, 0); } }
.hammer { width: 22px; height: 22px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 10l-9 9 2 2 9-9z' fill='%23d3a26a'/%3E%3Cpath d='M11 5l5-2 5 5-2 5-3-1-5-5z' fill='%23c8c6c0'/%3E%3C/svg%3E") center/contain no-repeat; }
#cards { display: flex; gap: 10px; max-width: min(96vw, 1000px); overflow-x: auto; overflow-y: visible; padding: 8px 6px 4px; scroll-snap-type: x proximity; touch-action: pan-x; scrollbar-width: thin; scrollbar-color: rgba(255, 246, 232, .35) transparent; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); }
#cards::-webkit-scrollbar { height: 6px; }
#cards::-webkit-scrollbar-thumb { background: rgba(255, 246, 232, .35); border-radius: 9px; }
.card { flex: none; scroll-snap-align: start; width: 150px; background: rgba(251, 243, 228, .99); color: var(--ink); border-radius: 16px; padding: 8px 10px 10px; text-align: left; box-shadow: 0 8px 22px rgba(30, 15, 5, .35); border: 2px solid transparent; transition: transform .15s, border-color .15s; position: relative; }
.card:hover { transform: translateY(-3px); border-color: var(--gold); }
.card.locked > * { opacity: .55; }
.card.locked { background: rgba(236, 226, 208, .98); }
.card.agelock { background: rgba(214, 202, 182, .98); }
.card.agelock .nm, .card.agelock .ds { opacity: .6; }
.card.agelock img { filter: grayscale(1) brightness(.9) contrast(.8); opacity: .55; }
.card.agelock .cost, .card.done .cost { display: none; }
.card.done img { opacity: .75; }
.card .lockmsg { display: none; font-size: 11.5px; font-weight: 800; color: #7a5a38; margin-top: 6px; line-height: 1.2; }
.card.agelock .lockmsg, .card.done .lockmsg, .card .lockmsg.needs { display: block; }
.card .lockmsg.needs { color: #c2412f; margin-top: 3px; }
.card.agelock .lockmsg::before { content: ''; display: inline-block; width: 10px; height: 11px; margin-right: 5px; vertical-align: -1px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 11'%3E%3Crect x='0' y='4.5' width='10' height='6.5' rx='1.5' fill='%237a5a38'/%3E%3Cpath d='M2.5 5V3.5a2.5 2.5 0 015 0V5' stroke='%237a5a38' stroke-width='1.4' fill='none'/%3E%3C/svg%3E") center/contain no-repeat; }
.card.done .lockmsg { color: #4c8a3a; }
.card.up { background: linear-gradient(180deg, rgba(255, 240, 210, .98), rgba(246, 226, 190, .96)); }
.card.pulse { animation: pulse 1.6s infinite; border-color: var(--gold); }
.card img { width: 100%; height: 84px; object-fit: contain; display: block; }
.card .nm { font-weight: 800; font-size: 15px; margin-top: 2px; }
.card .ds { font-size: 11.5px; color: #6b5a48; line-height: 1.25; min-height: 29px; }
.card .cost { display: flex; gap: 8px; margin-top: 6px; font-weight: 800; font-size: 13px; }
.card .cost span { display: flex; align-items: center; gap: 4px; }
.card .cost .ico { width: 18px; height: 18px; background-size: 13px; }
.card .cost .short { color: #c2412f; }

#placebar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; }
#placebar .row { display: flex; gap: 10px; align-items: center; }
#btn-rotate { font-size: 20px; padding: 8px 16px; }
#place-msg { background: var(--panel); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#place-msg.bad { color: #ffc0b5; }

#toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -10px); opacity: 0; pointer-events: none; text-align: center; transition: opacity .4s, transform .4s; background: rgba(43, 33, 24, .82); border: 1px solid rgba(242, 179, 91, .55); padding: 12px 26px; border-radius: 18px; box-shadow: 0 10px 30px rgba(30, 15, 5, .35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .k { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
#toast .t { font-family: var(--serif); font-size: 22px; font-weight: 700; margin-top: 2px; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.flt { position: absolute; transform: translate(-50%, -100%); font-weight: 900; font-size: 17px; color: #fff; text-shadow: 0 2px 0 rgba(60, 30, 10, .55), 0 0 10px rgba(60, 30, 10, .5); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.flt .ico { width: 20px; height: 20px; background-size: 14px; }
.pbar { position: absolute; transform: translate(-50%, -100%); width: 64px; height: 8px; border-radius: 99px; background: rgba(43, 33, 24, .7); border: 1px solid rgba(255, 246, 232, .4); overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, #f6be68, #e9783a); }
.chip { position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 5px; white-space: nowrap; background: rgba(43, 33, 24, .82); border: 1px solid rgba(239, 107, 91, .7); color: #ffd9cf; font-size: 12px; font-weight: 800; padding: 3px 10px 3px 4px; border-radius: 99px; }
.chip .ico { width: 18px; height: 18px; background-size: 12px; }
.chip:not(:has(.ico)) { padding-left: 10px; border-color: rgba(242, 179, 91, .6); color: #ffe6bf; }
#goal-arrow { position: absolute; width: 44px; height: 44px; border-radius: 50%; padding: 0; background: rgba(43, 33, 24, .78) center/24px no-repeat; border: 2px solid var(--gold); box-shadow: 0 4px 14px rgba(30, 15, 5, .35); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h12M11 6l6 6-6 6' stroke='%23ffc24a' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); animation: nudge 1.2s infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 8px rgba(242, 179, 91, .25); } }
#tooltip { position: fixed; z-index: 15; pointer-events: none; background: rgba(43, 33, 24, .86); border: 1px solid var(--line); padding: 6px 11px; border-radius: 10px; font-size: 13px; font-weight: 700; transform: translate(14px, 14px); white-space: nowrap; }
#tooltip small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }

#finale { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: radial-gradient(ellipse at center, rgba(30, 18, 8, .25) 20%, rgba(30, 18, 8, .7) 100%); animation: fadein 2.2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.fin-inner { max-width: 560px; animation: rise 2.4s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#finale h2 { font-family: var(--serif); font-size: clamp(44px, 9vw, 84px); margin: 10px 0 12px; line-height: 1; text-shadow: 0 4px 30px rgba(80, 35, 5, .6); }
#finale p { font-size: 17px; line-height: 1.5; color: #fff0db; text-shadow: 0 1px 10px rgba(0, 0, 0, .7); margin: 0 auto 18px; max-width: 470px; }
#banner { position: fixed; left: 0; right: 0; top: 16%; z-index: 25; text-align: center; pointer-events: none; padding: 0 20px; }
#banner.go { animation: banner 5.6s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateY(18px) scale(.96); letter-spacing: .02em; } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#banner h2 { font-family: var(--serif); font-size: clamp(38px, 8vw, 78px); margin: 8px 0 10px; line-height: 1; color: #fff7ea; text-shadow: 0 4px 30px rgba(80, 35, 5, .7), 0 2px 0 rgba(120, 60, 20, .5); }
#banner .kicker { font-size: 14px; color: var(--gold); }
#banner .rule { width: min(360px, 70vw); height: 2px; margin: 0 auto; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
#victory { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: radial-gradient(ellipse at center, rgba(30, 18, 8, .3) 20%, rgba(30, 18, 8, .74) 100%); animation: fadein 2.2s; overflow-y: auto; }
#victory h2 { font-family: var(--serif); font-size: clamp(44px, 9vw, 84px); margin: 10px 0 12px; line-height: 1; text-shadow: 0 4px 30px rgba(80, 35, 5, .6); }
#victory p { font-size: 17px; line-height: 1.5; color: #fff0db; text-shadow: 0 1px 10px rgba(0, 0, 0, .7); margin: 0 auto 18px; max-width: 470px; }
#vic-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 460px; margin: 0 auto 24px; }
#vic-stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px 9px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#vic-stats b { display: block; font-family: var(--serif); font-size: 26px; color: #fff7ea; }
#vic-stats span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
.tbc { font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--gold); margin-bottom: 26px; letter-spacing: .05em; }

@media (max-width: 640px) {
  #res { gap: 6px; max-width: 100%; right: 64px; }
  .pill { padding: 4px 10px 4px 4px; gap: 6px; }
  .pill span { display: none; }
  #res { gap: 5px; }
  #res .pill { padding: 3px 8px 3px 3px; gap: 4px; }
  #res .pill b { font-size: 14px; min-width: 14px; }
  #res .ico { width: 22px; height: 22px; background-size: 15px; }
  #banner { top: 22%; }
  #vic-stats b { font-size: 21px; }
  #victory p, #finale p { font-size: 15px; }
  .pill b { font-size: 16px; }
  .ico { width: 26px; height: 26px; background-size: 17px; }
  #goal { left: max(12px, env(safe-area-inset-left)); right: auto; top: calc(max(12px, env(safe-area-inset-top)) + 46px); width: min(300px, calc(100vw - 24px)); padding: 10px 12px; border-radius: 14px; }
  .goal-title { font-size: 17px; margin-bottom: 7px; }
  .goal-hint { font-size: 12px; }
  #cards { gap: 7px; }
  .card { width: 112px; padding: 6px 7px 8px; border-radius: 13px; }
  .card img { height: 62px; }
  .card .nm { font-size: 13px; }
  .card .ds { display: none; }
  .card .cost { font-size: 12px; gap: 5px; }
  #toast { top: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px); padding: 9px 18px; width: max-content; max-width: calc(100vw - 32px); }
  #toast .t { font-size: 18px; }
}

/* ---------- trading ---------- */
.ico.shells { background-color: #fde9d6; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20.5L3.2 9.6C5 5.6 8.3 3.5 12 3.5s7 2.1 8.8 6.1z' fill='%23f2b49a'/%3E%3Cpath d='M12 20.5L3.2 9.6M12 20.5l-5-13.2M12 20.5V3.6M12 20.5l5-13.2M12 20.5l8.8-10.9' stroke='%23c5745c' stroke-width='1.1' fill='none'/%3E%3Cpath d='M9.4 20.6h5.2l-1 1.6h-3.2z' fill='%23c5745c'/%3E%3C/svg%3E"); }
#res .pill.tap { cursor: pointer; transition: transform .2s, border-color .2s, background .2s; }
#res .pill.tap:hover { border-color: rgba(242, 179, 91, .7); }
#res .pill.tap:active { transform: scale(.95); }
#res .pill.sel { border-color: var(--gold); background: rgba(80, 52, 28, .88); box-shadow: 0 0 0 2px rgba(242, 179, 91, .35), 0 4px 14px rgba(30, 15, 5, .25); }
#res .pill.hint { animation: pulse 1.6s infinite; border-color: var(--gold); }
#r-shells b { color: #ffd9c4; }
.flyshell { position: fixed; z-index: 40; width: 22px; height: 22px; background-size: 16px; pointer-events: none; box-shadow: 0 2px 6px rgba(40, 20, 5, .4); }

#market { position: absolute; width: 320px; z-index: 12; background: rgba(43, 33, 24, .9); border: 1px solid rgba(242, 179, 91, .45); border-radius: 18px; padding: 12px 14px 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 14px 34px rgba(30, 15, 5, .45); animation: mkin .18s ease-out; }
@keyframes mkin { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.mk-head { display: flex; align-items: center; gap: 10px; }
.mk-head > .ico { width: 38px; height: 38px; background-size: 26px; }
.mk-title { flex: 1; min-width: 0; }
.mk-name { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.1; }
.mk-have { font-size: 12.5px; color: var(--muted); }
.mk-have b { color: var(--text); font-variant-numeric: tabular-nums; }
.mk-have span { opacity: .75; }
.mk-wallet { display: flex; align-items: center; gap: 5px; background: rgba(255, 246, 232, .1); border-radius: 99px; padding: 3px 10px 3px 3px; font-variant-numeric: tabular-nums; }
.mk-wallet .ico { width: 22px; height: 22px; background-size: 16px; }
.mk-wallet b { font-size: 15px; color: #ffd9c4; }
.mk-x { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 246, 232, .1); font-size: 20px; line-height: 1; padding: 0; color: var(--muted); flex: none; }
.mk-x:hover { background: rgba(255, 246, 232, .2); color: var(--text); }
.mk-tabs { display: flex; gap: 4px; margin-top: 11px; background: rgba(0, 0, 0, .22); border-radius: 99px; padding: 3px; }
.mk-tabs button { flex: 1; background: none; border-radius: 99px; padding: 6px 0; font-weight: 800; font-size: 13.5px; color: var(--muted); letter-spacing: .03em; }
.mk-tabs button.on { background: linear-gradient(180deg, #f6be68, #e48a3c); color: #3a1f0c; }
.mk-price { display: flex; align-items: center; gap: 8px; margin: 12px 2px 10px; }
.mk-lbl { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
.mk-val { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.mk-val .ico { width: 20px; height: 20px; background-size: 14px; }
.mk-val b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.tr { font-style: normal; font-size: 12px; font-weight: 900; margin-left: auto; padding: 2px 8px; border-radius: 99px; }
.tr.down { color: #ffb4a8; background: rgba(239, 107, 91, .18); }
.tr.up { color: #b9eb98; background: rgba(143, 209, 106, .16); }
.tr.flat { color: var(--muted); background: rgba(255, 246, 232, .08); font-size: 8px; padding: 4px 8px; }
.mk-price > span:last-child { margin-left: auto; }
.mk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mk-btn { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 6px 8px; border-radius: 13px; background: rgba(251, 243, 228, .96); color: var(--ink); box-shadow: 0 3px 0 rgba(120, 80, 40, .45); transition: transform .1s, filter .1s; }
.mk-btn b { font-size: 15px; font-weight: 800; }
.mk-btn small { font-size: 12px; font-weight: 800; color: #a3553a; font-variant-numeric: tabular-nums; }
.mk-btn:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.mk-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(120, 80, 40, .45); }
.mk-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.mk-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.35; }
.mk-note.warm { background: rgba(242, 179, 91, .12); border: 1px solid rgba(242, 179, 91, .3); border-radius: 11px; padding: 8px 10px; color: #ffe6bf; }
.mk-note:empty { display: none; }
.mk-auto { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.mk-autotxt { flex: 1; font-size: 13.5px; font-weight: 700; }
.mk-auto.off .mk-step b { opacity: .5; }
.mk-toggle { width: 40px; height: 23px; border-radius: 99px; background: rgba(255, 246, 232, .2); padding: 0; position: relative; flex: none; transition: background .2s; }
.mk-toggle i { position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff6e8; transition: transform .2s; }
.mk-toggle.on { background: var(--good); }
.mk-toggle.on i { transform: translateX(17px); }
.mk-step { display: flex; align-items: center; gap: 2px; background: rgba(0, 0, 0, .22); border-radius: 99px; padding: 2px; }
.mk-step button { width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 246, 232, .12); font-size: 17px; font-weight: 800; padding: 0; line-height: 1; }
.mk-step button:hover { background: rgba(255, 246, 232, .24); }
.mk-step b { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
@media (max-width: 640px) {
  #market { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 62px); padding: 11px 12px 12px; }
  .mk-btn { padding: 11px 6px 9px; }
}
@media (max-width: 640px) { #hud.mk-open #toast { bottom: auto; top: 38%; } #hud.mk-open #goal { opacity: .35; } }
