/* styles.css: how Tidebound looks. Parchment cards on a deep-sea background,
   gold and rope trim, big friendly buttons, and layouts that fold down to one
   column on a phone. */

:root {
  --sea: #0b1b2b;
  --sea2: #0f2a44;
  --sea3: #163a5c;
  --paper: #f3e6c4;
  --paper2: #e8d5a6;
  --ink: #2b1d10;
  --ink2: #5c4630;
  --gold: #e8b234;
  --gold2: #b8841a;
  --red: #c4402f;
  --green: #3f9a4f;
  --blue: #2f7bc4;
  --purple: #8a4fc4;
  --wood: #6b4226;
  --radius: 12px;
  --shadow: 0 4px 14px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--sea); }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: radial-gradient(ellipse at top, #1a4a72 0%, var(--sea2) 45%, var(--sea) 100%) fixed;
  color: #f4ecd8;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
h1, h2, h3 { font-family: 'Pirata One', 'Nunito', serif; font-weight: 400; letter-spacing: .5px; margin: .2em 0 .4em; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.35rem; }
h3 small, h2 small { font-family: 'Nunito', sans-serif; font-size: .8rem; opacity: .75; letter-spacing: 0; }
small { font-size: .82em; }
a { color: var(--gold); }
p { line-height: 1.45; margin: .4em 0; }
.muted { opacity: .65; }
.warn { color: #ffb340; font-weight: 700; }
.card .warn { color: #b0501a; }
.hint { font-size: .85rem; opacity: .75; }
.center { justify-content: center; }
.row { display: flex; gap: 6px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
svg { display: block; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 800; cursor: pointer;
  border: 2px solid #8a6a3a; border-radius: 10px;
  background: linear-gradient(#fff6dc, #e8d29c); color: var(--ink);
  padding: .5em .9em; box-shadow: 0 2px 0 #7a5a2a;
  transition: transform .08s, filter .15s;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 #7a5a2a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#ffd45a, #e09a1a); border-color: #8a5a10; }
.btn.danger { background: linear-gradient(#ff8a70, #c4402f); color: #fff; border-color: #7a2010; box-shadow: 0 2px 0 #6a1a0a; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .3); box-shadow: none; }
.card .btn.ghost { border-color: rgba(0, 0, 0, .25); }
.btn.small { padding: .3em .65em; font-size: .85rem; }
.btn.big { font-size: 1.1rem; padding: .7em 1.2em; }
.btn.big small { display: block; font-weight: 600; font-size: .75rem; opacity: .8; }
.btn.wide { width: 100%; }
.btn.on { background: linear-gradient(#ffd45a, #e09a1a); }
.btn.hold { position: relative; overflow: hidden; }
.btn.hold::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .25); transform: scaleX(0); transform-origin: left; }
.btn.hold.holding::after { transform: scaleX(1); transition: transform .9s linear; }
select {
  font: inherit; padding: .35em .4em; border-radius: 8px; border: 2px solid #8a6a3a; background: #fff8e6; color: var(--ink); max-width: 100%;
}
label { display: inline-flex; flex-direction: column; gap: 3px; font-size: .85rem; font-weight: 700; }

/* ---------- Cards (parchment) ---------- */
.card {
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper2) 100%);
  color: var(--ink); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(120, 80, 30, .25), inset 0 0 30px rgba(140, 100, 40, .2);
  overflow-wrap: anywhere;
}
.card h2, .card h3 { color: #3a2410; }
.card a { color: #8a4a10; }
.tag {
  display: inline-block; font-size: .72rem; font-weight: 800; padding: 1px 7px; border-radius: 99px;
  border: 1.5px solid currentColor; background: rgba(255, 255, 255, .55); color: var(--ink2); vertical-align: middle; text-transform: uppercase; letter-spacing: .3px;
}
.tag.gold { color: #9a6a00; }
.plus { color: #1f7a2f; font-weight: 700; margin-right: 10px; display: inline-block; }
.minus { color: #a8301f; font-weight: 700; margin-right: 10px; display: inline-block; }
.about { font-size: .9rem; color: var(--ink2); }

/* ---------- Bars ---------- */
.bar { position: relative; height: 18px; border-radius: 99px; background: rgba(0, 0, 0, .25); overflow: hidden; margin: 3px 0; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .4); min-width: 60px; }
.bar > span { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#7fd88f, #3f9a4f); transition: width .4s ease; border-radius: 99px; }
.bar > em { position: relative; display: block; text-align: center; font-style: normal; font-size: .72rem; font-weight: 900; line-height: 18px; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.thin { height: 8px; }
.bar.thin > em { display: none; }
.bar.hp > span { background: linear-gradient(#ff8b7a, #c4402f); }
.bar.hp.foe > span { background: linear-gradient(#c49aff, #7a3fc4); }
.bar.happy > span { background: linear-gradient(#ffe27a, #e0a01a); }
.bar.xp > span { background: linear-gradient(#8fd0ff, #2f7bc4); }
.bar.spirit > span { background: linear-gradient(#d4a0ff, #7a3fc4); }
.bar.st > span { background: linear-gradient(#a8f0c0, #2fa86a); }
.bar.low > span { background: linear-gradient(#ff8b7a, #a8301f); }

/* ---------- Loading and title ---------- */
.loading { min-height: 100vh; display: grid; place-content: center; text-align: center; }
.logo { font-family: 'Pirata One', serif; font-size: clamp(3rem, 12vw, 6rem); line-height: .95; margin: 0; color: var(--gold); text-shadow: 0 3px 0 #6a3a0a, 0 6px 18px rgba(0, 0, 0, .6); }
.logo small { display: block; font-size: .38em; color: #fff0c8; letter-spacing: 2px; }
.title-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 16px 30px; }
.title-art { width: 100%; max-width: 900px; height: 220px; margin-bottom: -40px; border-radius: 0 0 40% 40% / 0 0 30px 30px; overflow: hidden; }
.title-art svg { width: 100%; height: 100%; }
.title-art svg g { animation: bob 4s ease-in-out infinite; transform-box: fill-box; }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: -1deg; } 50% { translate: 0 6px; rotate: 1.5deg; } }
.tagline { max-width: 34em; opacity: .9; margin-top: 10px; }
.who { opacity: .8; font-size: .9rem; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); margin: 16px 0; }
.title-links { font-size: .85rem; opacity: .8; }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, .45); flex-wrap: wrap; }
.slot.empty { opacity: .6; }
.grave { padding: 10px; border-left: 4px solid #8a7a6a; background: rgba(255, 255, 255, .35); border-radius: 6px; margin-bottom: 8px; }

/* ---------- New life ---------- */
.create { max-width: 1100px; margin: 0 auto; padding: 12px 16px 100px; }
.create-head { display: flex; align-items: center; gap: 14px; }
.create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.create-grid .span2 { grid-column: span 2; }
.preview { display: flex; gap: 16px; align-items: center; }
.preview svg, .life-head svg { flex: none; border-radius: 50%; background: #c8e4f4; box-shadow: inset 0 0 0 3px #8a6a3a; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 10px 0 0 10px; }
.seg .btn:last-child { border-radius: 0 10px 10px 0; }
.card .row.wrap { margin: 6px 0; align-items: flex-end; }
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pick { font: inherit; cursor: pointer; border: 2px solid transparent; border-radius: 10px; background: rgba(255, 255, 255, .45); padding: 4px; color: var(--ink); display: flex; flex-direction: column; align-items: center; }
.pick svg { width: 100%; height: auto; border-radius: 8px; }
.pick.on, .pick-row.on, .trait.on { border-color: var(--gold2); background: #fff3c8; box-shadow: 0 0 0 2px var(--gold); }
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; padding: 2px; }
.pick-row { font: inherit; cursor: pointer; text-align: left; border: 2px solid transparent; border-radius: 8px; background: rgba(255, 255, 255, .4); padding: 6px 9px; color: var(--ink); }
.pick-row small { display: block; color: var(--ink2); }
.pick-row:disabled { opacity: .5; cursor: not-allowed; }
.trait-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.trait { font: inherit; cursor: pointer; text-align: left; border: 2px solid transparent; border-radius: 8px; background: rgba(255, 255, 255, .4); padding: 6px 9px; color: var(--ink); }
.trait small { display: block; color: var(--ink2); font-size: .75rem; }
.create-go { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(5, 15, 25, .95) 35%); flex-wrap: wrap; }

/* ---------- The game frame ---------- */
.game { max-width: 1100px; margin: 0 auto; padding-bottom: 90px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: linear-gradient(#3a2414, #2a180c); border-bottom: 3px solid var(--gold2); box-shadow: var(--shadow); }
.top-portrait { border: 0; padding: 0; background: #c8e4f4; border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 2px var(--gold); flex: none; }
.top-portrait svg { border-radius: 50%; }
.top-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-info small { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-money { text-align: right; font-weight: 900; color: var(--gold); display: flex; flex-direction: column; }
.bounty-mini { color: #ff9a8a; }
.tabs { display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; scrollbar-width: thin; }
.tab { position: relative; font: inherit; cursor: pointer; flex: 1 0 auto; min-width: 72px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 10px; border: 2px solid rgba(232, 178, 52, .35); background: rgba(10, 30, 50, .7); color: #f4ecd8; }
.tab span { font-size: 1.25rem; }
.tab small { font-weight: 800; font-size: .72rem; }
.tab.on { background: linear-gradient(#ffd45a, #e09a1a); color: var(--ink); border-color: #8a5a10; }
.dot { position: absolute; top: -4px; right: -2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--red); color: #fff; font-style: normal; font-size: .7rem; font-weight: 900; line-height: 18px; }
.panel { padding: 4px 16px; }

/* Tablet and computer: the tabs down the left side. */
@media (min-width: 900px) {
  .game { display: grid; grid-template-columns: 170px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: span 2; }
  .tabs { flex-direction: column; overflow: visible; position: sticky; top: 70px; align-self: start; padding: 14px 0 14px 16px; }
  .tab { flex-direction: row; gap: 8px; justify-content: flex-start; flex: none; }
  .tab small { font-size: .85rem; }
  .panel { padding: 14px 16px; }
}

/* ---------- Life ---------- */
.life { display: grid; grid-template-columns: minmax(0, 1fr); }
.life-head { display: flex; gap: 14px; align-items: center; }
.life-who h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: .8rem; font-weight: 800; padding: 2px 9px; border-radius: 99px; background: rgba(0, 0, 0, .1); }
.chip.gold { background: #ffe9a8; color: #7a5200; }
.chip.red { background: #ffd0c8; color: #8a1f10; }
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.meters label { display: block; }
.ageup-wrap { display: flex; flex-direction: column; align-items: center; margin: 4px 0 16px; }
.ageup {
  font-family: 'Pirata One', serif; cursor: pointer; border: 4px solid #6a3a0a; border-radius: 999px; padding: 14px 56px;
  background: radial-gradient(circle at 50% 30%, #ffe27a, #e09a1a 60%, #a8640a); color: #3a1a00; font-size: 2.1rem; line-height: 1;
  box-shadow: 0 6px 0 #5a2a05, 0 10px 24px rgba(0, 0, 0, .5); transition: transform .1s; display: flex; flex-direction: column; align-items: center;
  animation: pulse 2.4s ease-in-out infinite;
}
.ageup small { font-family: 'Nunito', sans-serif; font-size: .9rem; font-weight: 900; }
.ageup:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #5a2a05; }
.ageup:disabled { filter: grayscale(.7); animation: none; cursor: not-allowed; }
@keyframes pulse { 0%, 100% { box-shadow: 0 6px 0 #5a2a05, 0 10px 24px rgba(0, 0, 0, .5); } 50% { box-shadow: 0 6px 0 #5a2a05, 0 10px 30px rgba(255, 200, 60, .45); } }
.actions-left { margin: 10px 0 0; text-align: center; }
.act-grid, .train-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.act { font: inherit; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 10px; border: 2px solid #b8945a; background: rgba(255, 255, 255, .55); color: var(--ink); transition: transform .08s, background .15s; }
.act:hover:not(:disabled) { background: #fff6d8; }
.act:active:not(:disabled) { transform: scale(.97); }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act span { font-size: 1.4rem; }
.act small { color: var(--ink2); font-size: .75rem; }
.shop-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.order { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; align-items: center; padding: 4px 0; }
.story { list-style: none; padding: 0; margin: 0; max-height: 460px; overflow-y: auto; }
.story li { padding: 5px 2px; border-bottom: 1px dashed rgba(90, 60, 30, .25); font-size: .92rem; }
.story li.year { padding-top: 10px; color: #6a3a10; }
.story li.good { color: #1f6a2f; }
.story li.bad { color: #9a2a1a; }
.story li.big { font-weight: 800; color: #6a2a8a; }

/* ---------- Map ---------- */
.map-box { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow), 0 0 0 3px var(--gold2); margin-bottom: 14px; background: #0d3b63; }
#worldmap { width: 100%; height: auto; aspect-ratio: 16 / 10; touch-action: none; cursor: grab; user-select: none; }
#worldmap:active { cursor: grabbing; }
.map-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-zoom .btn { width: 38px; height: 38px; padding: 0; font-size: 1.2rem; }
.map-legend { position: absolute; left: 8px; bottom: 6px; font-size: .72rem; background: rgba(0, 0, 0, .55); padding: 3px 8px; border-radius: 6px; display: flex; gap: 5px; align-items: center; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.lg.g { background: #6fd08c; } .lg.y { background: #ffb340; } .lg.r { background: #ff5d5d; }
.map-sea { fill: #ffffff; fill-opacity: .55; font-family: 'Pirata One', serif; font-size: 34px; text-anchor: middle; letter-spacing: 3px; pointer-events: none; }
.map-spine { fill: #ffd8c8; font-size: 26px; }
.map-sub { fill: #bfe3ff; fill-opacity: .6; font-size: 18px; font-style: italic; text-anchor: middle; pointer-events: none; }
.map-route { stroke: #ffe27a; stroke-width: 2.5; stroke-dasharray: 8 7; opacity: .7; pointer-events: none; }
.map-isl { cursor: pointer; outline: none; }
.map-isl:hover circle:nth-child(2), .map-isl:focus circle:nth-child(2) { fill: #fff6c8; }
.map-isl.sel circle:nth-child(2) { fill: #ffd45a; stroke: #fff; stroke-width: 3; }
.map-name { fill: #fff; font-size: 17px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: #0a2238; stroke-width: 4px; pointer-events: none; }
.map-lvl { fill: #fff; font-size: 13px; font-weight: 900; text-anchor: middle; paint-order: stroke; stroke: #000; stroke-width: 3px; pointer-events: none; }
.map-flag { fill: #ff5d5d; font-size: 18px; pointer-events: none; }
.map-you { pointer-events: none; animation: bob 3s ease-in-out infinite; }
.isl-card { display: flex; gap: 14px; align-items: flex-start; }
.isl-card > svg { flex: none; width: 200px; height: auto; border-radius: 10px; }
.isl-card > div { flex: 1; min-width: 0; }
.isl-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: .9rem; }
.isl-facts dt { font-weight: 800; }
.isl-facts dd { margin: 0; }
.sail-info { font-size: .9rem; }
.sail-no { font-weight: 700; color: #8a2a1a; }

/* ---------- Character ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.stat { display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: rgba(255, 255, 255, .4); border-radius: 8px; }
.stat > div { flex: 1; }
.s-ico { font-size: 1.4rem; }
.s-val { font-weight: 900; font-size: 1.1rem; color: #6a3a10; }
.s-about { display: block; color: var(--ink2); font-size: .72rem; }
.pts { color: #b0301a; }
.nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin-bottom: 8px; }
.nums > div { background: rgba(255, 255, 255, .4); border-radius: 8px; padding: 6px 9px; display: flex; flex-direction: column; }
.spirit { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px dashed rgba(90, 60, 30, .25); }
.people { list-style: none; padding: 0; margin: 0; }
.people li { padding: 4px 0; }
.fights { padding-left: 1.2em; margin: 0; font-size: .9rem; }
.fights li.win b { color: #1f7a2f; }
.fights li.lose b { color: #a8301f; }

/* ---------- Fruit, items, swords ---------- */
.fruit-head, .sword-head, .ship-head, .fac-head { display: flex; gap: 14px; align-items: center; }
.fruit-head svg, .sword-head svg { flex: none; }
.moves { padding-left: 1.1em; }
.moves li { padding: 3px 0; }
.moves li.locked { opacity: .55; }
.moves li.awake b { color: #8a3fc4; }
.item-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed rgba(90, 60, 30, .25); }
.item-row > div:first-of-type, .item-row > div:nth-child(2):not(.row) { flex: 1; min-width: 0; }
.item-row small { display: block; color: var(--ink2); }
.item-row .row { flex: none; flex-wrap: wrap; justify-content: flex-end; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.codex-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 6px 4px; border-radius: 8px; background: rgba(255, 255, 255, .4); font-size: .85rem; }
.codex-item.unknown { opacity: .55; font-size: 1.3rem; }
.codex-item.unknown small { font-size: .7rem; }
.codex-item.have { background: #fff1b8; box-shadow: 0 0 0 2px var(--gold); }
.equip { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.equip > div { background: rgba(255, 255, 255, .4); border-radius: 8px; padding: 6px 9px; display: flex; flex-direction: column; }
details.grade { border-bottom: 1px dashed rgba(90, 60, 30, .25); padding: 6px 0; }
details summary { cursor: pointer; padding: 4px 0; }

/* ---------- Crew, quests, faction ---------- */
.ship-ico, .fac-ico { font-size: 2.6rem; flex: none; }
.crew-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed rgba(90, 60, 30, .25); }
.crew-row > div { flex: 1; min-width: 0; }
.crew-row small { display: block; color: var(--ink2); }
.role { font-size: 1.8rem; flex: none; }
label.mini { display: block; font-size: .72rem; }
.quest { padding: 8px 0; border-bottom: 1px dashed rgba(90, 60, 30, .25); }
.quest > small { color: #8a5a10; font-weight: 800; text-transform: uppercase; font-size: .7rem; }
.quest b { display: block; font-size: 1.05rem; }
.reward { font-size: .85rem; color: #1f6a2f; font-weight: 700; }
.wanted { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.poster { flex: none; width: 110px; text-align: center; padding: 8px 4px; background: #f8ecc8; border: 2px solid #8a6a3a; box-shadow: 2px 3px 0 rgba(0, 0, 0, .25); font-family: 'Pirata One', serif; transform: rotate(-2deg); }
.poster small { display: block; font-size: 1.1rem; letter-spacing: 2px; }
.poster b { display: block; font-family: 'Nunito', sans-serif; font-size: .8rem; }
.poster span { display: block; font-size: 1.1rem; color: #8a2a1a; }
.ranks { padding-left: 1.4em; font-size: .9rem; }
.ranks li.got { font-weight: 800; color: #1f6a2f; }
.join { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed rgba(90, 60, 30, .25); }
.join > div { flex: 1; min-width: 0; }
.join small { display: block; color: var(--ink2); }
.join .fac-ico { font-size: 1.8rem; }
label.standing { display: block; margin: 4px 0; }

/* ---------- Achievements ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.ach-item { display: flex; gap: 8px; align-items: center; padding: 7px 9px; border-radius: 8px; background: rgba(255, 255, 255, .35); opacity: .6; }
.ach-item span { font-size: 1.4rem; }
.ach-item small { display: block; color: var(--ink2); }
.ach-item.got { opacity: 1; background: #fff1b8; box-shadow: inset 0 0 0 2px var(--gold); }

/* ---------- Windows on top ---------- */
#modal { position: relative; z-index: 20; }
.modal-back { position: fixed; inset: 0; background: rgba(2, 10, 20, .72); backdrop-filter: blur(2px); animation: fade .2s; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  display: flex; flex-direction: column; border-radius: 16px; color: var(--ink);
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper2) 100%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6), inset 0 0 0 3px #a8844a; animation: popin .22s ease-out;
}
.modal.wide { width: min(860px, calc(100vw - 24px)); }
.modal-body { overflow-y: auto; padding: 18px 18px 20px; overscroll-behavior: contain; }
.modal-body .card { box-shadow: none; background: rgba(255, 255, 255, .3); }
.modal.still, .modal-back.still, .modal.still .event-icon { animation: none; }
.modal-x { position: absolute; right: 8px; top: 8px; z-index: 2; border: 0; background: rgba(0, 0, 0, .12); width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; cursor: pointer; color: var(--ink); }
@keyframes popin { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes fade { from { opacity: 0; } }
.modal h2 { padding-right: 34px; }
.purse { margin-top: -4px; }
.event { text-align: center; }
.event-icon { font-size: 3.4rem; line-height: 1; animation: wiggle 1.2s ease-in-out; }
@keyframes wiggle { 0% { transform: scale(.4) rotate(-20deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: none; } }
.event-age { margin: -6px 0 6px; font-weight: 800; color: #8a5a10; }
.event-text { font-size: 1.05rem; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice { font: inherit; font-weight: 800; cursor: pointer; padding: 11px 14px; border-radius: 10px; border: 2px solid #8a6a3a; background: #fff8e2; color: var(--ink); text-align: left; transition: background .15s, transform .08s; }
.choice:hover:not(:disabled) { background: #ffeeb0; }
.choice:active:not(:disabled) { transform: scale(.98); }
.choice:disabled { opacity: .5; cursor: not-allowed; }
.choice small { display: block; font-weight: 600; color: #8a2a1a; }
.foe-preview { display: flex; gap: 12px; align-items: center; justify-content: center; text-align: left; margin: 10px 0; }
.foe-preview > div { display: flex; flex-direction: column; }
.threat { font-weight: 900; text-transform: uppercase; font-size: .8rem; }
.threat.easy { color: #1f7a2f; } .threat.fair { color: #2f6ac4; } .threat.hard { color: #c46a0a; } .threat.deadly { color: #b0201a; }

/* Fights */
.fighters { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.fighter { display: flex; gap: 8px; align-items: center; }
.fighter > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fighter.foe { flex-direction: row-reverse; text-align: right; }
.fighter svg { flex: none; }
.vs { font-family: 'Pirata One', serif; font-size: 1.8rem; color: #8a2a1a; text-align: center; display: flex; flex-direction: column; }
.vs small { font-family: 'Nunito', sans-serif; font-size: .7rem; color: var(--ink2); }
.fight-log { list-style: none; padding: 8px 10px; margin: 10px 0; height: 170px; overflow-y: auto; background: rgba(40, 25, 10, .85); color: #f4ecd8; border-radius: 10px; font-size: .86rem; }
.fight-log li { padding: 2px 0; }
.fight-log li.good { color: #9af0a8; }
.fight-log li.bad { color: #ff9a8a; }
.fight-log li.big { color: #ffd45a; font-weight: 900; }
.move-groups { display: flex; flex-direction: column; gap: 6px; }
.moves-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.group-name { width: 100%; font-weight: 800; color: var(--ink2); }
.move { font: inherit; cursor: pointer; flex: 1 1 130px; text-align: left; padding: 6px 9px; border-radius: 9px; border: 2px solid #8a6a3a; background: #fff8e2; color: var(--ink); display: flex; flex-direction: column; }
.move b { font-size: .9rem; }
.move small { font-size: .7rem; color: var(--ink2); }
.move.fruit { background: #ffe8f2; border-color: #c4508a; }
.move.spirit { background: #efe2ff; border-color: #7a3fc4; }
.move:disabled { opacity: .45; cursor: not-allowed; }
.move:active:not(:disabled) { transform: scale(.97); }
.fight-end { text-align: center; padding: 8px; border-radius: 10px; animation: popin2 .3s; }
@keyframes popin2 { from { transform: scale(.9); opacity: 0; } }
.fight-end.win h2 { color: #1f7a2f; }
.fight-end.lose h2 { color: #a8201a; }

/* Auction */
.bid { font-size: 1.1rem; }
.modal .fight-log { height: 130px; }

/* Death */
.death { text-align: center; }
.death > svg { margin: 0 auto; border-radius: 50%; background: #c8d4dc; filter: grayscale(.6); }
.cause { font-style: italic; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; text-align: left; max-width: 520px; margin: 10px auto; font-size: .92rem; }
.summary dt { font-weight: 800; }
.summary dd { margin: 0; }
.score { font-size: 1.2rem; }
.death .row { margin-top: 12px; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.toggle { flex-direction: row; align-items: center; gap: 8px; font-size: .95rem; }
.toggle input { width: 20px; height: 20px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 50; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: rgba(20, 30, 45, .95); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); border-left: 5px solid var(--blue); font-weight: 700; font-size: .92rem; animation: toastin .25s ease-out; transition: opacity .5s, transform .5s; }
.toast.good { border-color: var(--green); }
.toast.bad { border-color: var(--red); }
.toast.gold { border-color: var(--gold); background: rgba(60, 40, 10, .96); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  h2 { font-size: 1.45rem; }
  .create-grid { grid-template-columns: minmax(0, 1fr); }
  .create-grid .span2 { grid-column: auto; }
  .meters { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .life-head svg, .preview svg { width: 76px; height: 76px; }
  .ageup { padding: 12px 44px; font-size: 1.8rem; }
  .isl-card { flex-direction: column; }
  .isl-card > svg { width: 100%; }
  .tabs { padding: 6px 10px; }
  .tab { min-width: 64px; }
  .panel { padding: 4px 10px; }
  .topbar { padding: 6px 10px; }
  .fighters { grid-template-columns: minmax(0, 1fr); }
  .fighter.foe { flex-direction: row; text-align: left; }
  .vs { flex-direction: row; justify-content: center; gap: 8px; align-items: baseline; font-size: 1.3rem; }
  .fighter svg { width: 48px; height: 48px; }
  .fight-log { height: 120px; }
  .modal-body { padding: 14px 12px 16px; }
  .item-row { flex-wrap: wrap; }
  .order { grid-template-columns: 1fr 70px auto; }
  .act-grid, .train-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
