/* Game screens. Base tokens and buttons are in base.css. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--paper); background-image: url("../assets/tex/paper.webp"); background-size: 512px; }
.app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row .grow, .grow { flex: 1; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.err { color: var(--coral-2); font-size: 14px; margin: 8px 0 0; }
.icon-btn { border: 0; background: transparent; font-size: 24px; width: 40px; height: 40px; border-radius: 12px; cursor: pointer; color: var(--ink-2); line-height: 1; }
.icon-btn:hover { background: rgba(110, 80, 50, .08); }
.ico { display: inline-block; vertical-align: -5px; object-fit: contain; }

/* loading / offline / login */
.loading, .offline { position: absolute; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: linear-gradient(180deg, #d9ebe6, #f5eedc); color: var(--ink-2); font-size: 16px; letter-spacing: .08em; transition: opacity .6s; }
.loading.done { opacity: 0; pointer-events: none; }
.offline { background: rgba(245, 238, 220, .92); }
.offline .paper { padding: 22px 26px; max-width: 360px; text-align: center; }
.offline h2 { margin: 0 0 6px; }
.dots { display: flex; gap: 8px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: bounce 1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; background: var(--moss); }
.dots i:nth-child(3) { animation-delay: .3s; background: var(--sand); }
@keyframes bounce { 50% { transform: translateY(-10px); } }
.login { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, rgba(246, 239, 225, .2), rgba(246, 239, 225, .55)); }
.login-card { width: min(380px, 100%); padding: 22px 24px 18px; text-align: center; }
.login-logo { width: 110px; height: 90px; object-fit: contain; margin: -6px auto 0; display: block; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-5px); } }
.login h1 { margin: 2px 0 2px; font-size: 34px; letter-spacing: .2em; color: var(--ink); }
.login .sub { margin: 0 0 12px; color: var(--ink-3); font-size: 14px; }
.login label { display: block; text-align: left; font-size: 14px; color: var(--ink-2); margin: 8px 0 0; }
.login input { display: block; width: 100%; margin-top: 4px; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(110, 80, 50, .3); background: #fffdf8; font-size: 16px; }
.login input:focus { outline: 2px solid rgba(217, 114, 90, .4); border-color: var(--coral); }
.login .row { margin-top: 14px; }
.avatars { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.avatars button { width: 76px; height: 86px; border-radius: 14px; border: 2px solid transparent; background: rgba(255, 250, 240, .8); cursor: pointer; padding: 4px; }
.avatars button[aria-pressed="true"] { border-color: var(--coral); background: #fff; }
.avatars img { width: 100%; height: 100%; object-fit: contain; }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.plate { position: absolute; left: 14px; top: max(14px, env(safe-area-inset-top)); min-width: 230px; max-width: 300px; text-align: left; display: grid; gap: 2px;
  padding: 12px 16px 10px; border-radius: 16px 16px 16px 4px; border: 1px solid rgba(120, 85, 50, .18); cursor: pointer; font: inherit; color: inherit;
  background: linear-gradient(180deg, rgba(253, 249, 240, .96), rgba(246, 237, 220, .96)); box-shadow: var(--shadow); }
.plate:hover { background: #fffaf0; }
.plate-name { font-size: 23px; font-weight: 600; letter-spacing: .06em; line-height: 1.2; }
.plate-name::after { content: " ▾"; font-size: 14px; color: var(--ink-3); }
.plate-sub { font-size: 12.5px; color: var(--ink-3); letter-spacing: .1em; }
.dev { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.dev b { color: var(--coral-2); font-size: 14px; }
.bar { flex: 1; height: 8px; min-width: 60px; border-radius: 8px; background: rgba(110, 80, 50, .14); overflow: hidden; box-shadow: inset 0 1px 2px rgba(60, 40, 20, .2); display: block; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8fbf6c, #6e9a5a); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.plate-hint { font-size: 12px; color: var(--ink-3); }
.pills { position: absolute; right: 14px; top: max(14px, env(safe-area-inset-top)); display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 340px); }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px 0 5px; background: rgba(253, 249, 240, .94); border-radius: 18px;
  box-shadow: var(--shadow); border: 1px solid rgba(120, 85, 50, .16); font-size: 14px; font-variant-numeric: tabular-nums; }
.pill small { color: var(--ink-3); font-size: 11.5px; }
.bell { position: absolute; right: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 44px); height: 34px; padding: 0 14px; border-radius: 18px; border: 1px solid rgba(120, 85, 50, .16);
  background: rgba(253, 249, 240, .94); box-shadow: var(--shadow); cursor: pointer; font-size: 14px; }
.bell i { display: inline-block; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--coral); color: #fff; font-style: normal; font-size: 12px; line-height: 18px; }
.catch-btn { position: absolute; right: 18px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff3e6;
  background: radial-gradient(circle at 35% 30%, #ef9a80, var(--coral) 55%, var(--coral-2)); color: #fff8ef; font-size: 19px; font-weight: 600; cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(140, 60, 30, .7), 0 0 0 6px rgba(217, 114, 90, .18); animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 10px 24px -10px rgba(140, 60, 30, .7), 0 0 0 11px rgba(217, 114, 90, .1); } }
.nav { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; border-radius: 22px;
  background: rgba(253, 249, 240, .94); box-shadow: var(--shadow); border: 1px solid rgba(120, 85, 50, .16); max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; }
.nav button { border: 0; background: transparent; border-radius: 16px; padding: 8px 15px; white-space: nowrap; cursor: pointer; font-size: 15px; color: var(--ink-2); }
.nav button:hover { background: rgba(110, 80, 50, .08); }
.nav button[aria-pressed="true"] { background: var(--ink); color: #fff8ea; }
.nav button i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-left: 4px; vertical-align: 2px; }
.clock { position: absolute; left: 14px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 3px; padding: 4px; border-radius: 18px;
  background: rgba(253, 249, 240, .9); box-shadow: var(--shadow); border: 1px solid rgba(120, 85, 50, .16); }
.clock button { border: 0; padding: 0 9px; height: 30px; border-radius: 14px; background: transparent; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.clock button[aria-pressed="true"] { background: var(--ink); color: #fff8ea; }

/* tooltip */
.tip { position: fixed; z-index: 30; pointer-events: none; min-width: 170px; max-width: 280px; padding: 9px 13px; border-radius: 12px;
  background: rgba(253, 249, 240, .97); box-shadow: var(--shadow); border: 1px solid rgba(120, 85, 50, .2); font-size: 13.5px; line-height: 1.6; }
.tip h4 { margin: 0 0 2px; font-size: 15px; }
.tip p { margin: 0; color: var(--ink-2); }

/* sheet (side panel on desktop, bottom sheet on phones) */
.sheet { position: absolute; z-index: 20; right: 14px; top: 64px; bottom: 76px; width: min(430px, calc(100% - 28px)); display: flex; flex-direction: column;
  background-image: url("../assets/tex/paper.webp"); background-size: 420px; border-radius: 18px; box-shadow: 0 30px 60px -30px rgba(50, 30, 10, .6), var(--shadow);
  animation: slidein .3s cubic-bezier(.2, .8, .2, 1); overflow: hidden; }
.sheet.wide { width: min(760px, calc(100% - 28px)); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 6px 18px; border-bottom: 1px dashed var(--line); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 20px; letter-spacing: .04em; }
.sheet-body { flex: 1; overflow-y: auto; padding: 12px 18px 22px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.sheet h3 { margin: 16px 0 6px; font-size: 16px; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sheet h3:first-child { margin-top: 2px; }
.sheet h3 small { font-weight: 400; font-size: 12.5px; color: var(--ink-3); }
.sheet p { margin: 4px 0; font-size: 14.5px; line-height: 1.7; color: var(--ink-2); }
.sheet select, .sheet input[type=number], .sheet input[type=text] { padding: 5px 8px; border-radius: 9px; border: 1px solid rgba(110, 80, 50, .3); background: #fffdf7; font-size: 15px; }
.sheet input[type=number] { width: 80px; }

.card { padding: 10px 12px; border-radius: 13px; background: rgba(255, 252, 245, .85); border: 1px solid rgba(110, 80, 50, .14); margin: 8px 0; }
.card.click { cursor: pointer; transition: background .15s, transform .15s; }
.card.click:hover { background: #fff; transform: translateY(-1px); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; }
.mini { position: relative; padding: 6px; border-radius: 12px; background: rgba(255, 252, 245, .85); border: 1px solid rgba(110, 80, 50, .14); text-align: center; cursor: pointer; transition: transform .15s, background .15s; }
.mini:hover { transform: translateY(-2px); background: #fff; }
.mini.on { border-color: var(--coral); box-shadow: 0 0 0 2px rgba(217, 114, 90, .3); }
.mini canvas { width: 100%; aspect-ratio: 1; display: block; }
.mini b { display: block; font-weight: 400; font-size: 14px; }
.mini small { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
.badge { position: absolute; left: 6px; top: 6px; font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--ink); color: #fff8ea; }
.badge.sleep { background: #6c6a92; } .badge.idle { background: #a08a6c; } .badge.work { background: var(--moss); } .badge.egg { background: var(--sand); color: var(--ink); } .badge.travel { background: var(--teal); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.tag { font-size: 12.5px; padding: 1px 9px; border-radius: 10px; background: rgba(110, 80, 50, .08); color: var(--ink-2); border: 1px solid rgba(110, 80, 50, .12); }
.tag.good { background: rgba(110, 154, 90, .14); color: var(--moss-2); border-color: rgba(110, 154, 90, .3); }
.tag.bad { background: rgba(217, 114, 90, .12); color: var(--coral-2); border-color: rgba(217, 114, 90, .3); }
.tag.mut { background: linear-gradient(90deg, #f3e3ff, #dff6ef); border-color: #c9b6e6; color: #6b4b8c; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; margin: 6px 0; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.genes { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0; }
.genes td, .genes th { padding: 5px 2px; border-top: 1px dashed var(--line); text-align: left; }
.genes th { font-weight: 400; font-size: 12px; color: var(--ink-3); border-top: 0; }
.genes td:last-child { text-align: right; }
.al { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; padding: 0 6px; border-radius: 7px; background: #fff; border: 1px solid rgba(110, 80, 50, .25); white-space: nowrap; }
.portrait { position: relative; aspect-ratio: 4 / 3.1; border-radius: 14px; overflow: hidden; background: radial-gradient(120% 90% at 50% 100%, #e8dcc2, #f7f0e1 60%); }
.portrait canvas { width: 100%; height: 100%; display: block; }
.portrait .stamp { position: absolute; left: 12px; top: 9px; font-size: 12px; letter-spacing: .15em; color: var(--ink-3); }
.who { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 0; }
.who h3 { margin: 0; font-size: 24px; color: var(--ink); }
.who span { color: var(--ink-3); font-size: 13.5px; }
.formula { margin: 6px 0; padding: 8px 10px; border-radius: 11px; background: rgba(79, 154, 147, .08); border: 1px solid rgba(79, 154, 147, .2); font-size: 13.5px; }
.formula .f { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.formula .f span:last-child { font-variant-numeric: tabular-nums; }
.formula .f.low span:last-child { color: var(--coral-2); }
.formula .f.high span:last-child { color: var(--moss-2); }
.formula .how { color: var(--teal); font-size: 12.5px; cursor: pointer; text-decoration: underline dotted; }
.cost { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ci { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.ci.short { color: var(--coral-2); }
.stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin: 6px 0; }
.stock > div { display: flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 10px; background: rgba(255, 252, 245, .8); border: 1px solid rgba(110, 80, 50, .12); font-size: 13.5px; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(110, 80, 50, .08); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 11px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(60, 40, 20, .2); }
.odds { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 8px; }
.odd { padding: 6px; border-radius: 12px; background: rgba(255, 252, 245, .85); border: 1px solid rgba(110, 80, 50, .14); text-align: center; }
.odd canvas { width: 100%; aspect-ratio: 1; }
.odd b { display: block; font-size: 17px; color: var(--coral-2); font-variant-numeric: tabular-nums; }
.odd span { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.tree { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tree h4 { margin: 0 0 4px; font-size: 14px; color: var(--ink-3); text-align: center; letter-spacing: .2em; }
.tech { padding: 8px 9px; border-radius: 12px; border: 1px solid rgba(110, 80, 50, .16); background: rgba(255, 252, 245, .7); margin-bottom: 8px; font-size: 13px; }
.tech b { display: block; font-size: 15px; }
.tech.done { background: rgba(110, 154, 90, .14); border-color: rgba(110, 154, 90, .35); }
.tech.avail { border-color: var(--coral); }
.tech.locked { opacity: .55; }
.tech p { font-size: 12.5px !important; line-height: 1.5 !important; margin: 3px 0 !important; }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; line-height: 1.6; }
.news li small { display: block; color: var(--ink-3); font-size: 12px; }
.news li.me { color: var(--ink); }
.lock { color: var(--ink-3); font-size: 13px; }
.regions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.region-card { padding: 10px; border-radius: 14px; border: 1px solid rgba(110, 80, 50, .16); background: rgba(255, 252, 245, .85); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.region-card:hover { background: #fff; }
.region-card b { display: block; font-size: 16px; }
.region-card i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.region-card.on { border-color: var(--coral); }
.almanac-tabs { margin-bottom: 8px; }
.sp-row { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: center; }
.sp-row img { width: 84px; height: 84px; object-fit: contain; background: radial-gradient(110% 90% at 50% 100%, #e8dcc2, #f8f2e5 62%); border-radius: 12px; }
.att { display: flex; flex-wrap: wrap; gap: 4px; }
.att span { font-size: 12px; padding: 0 7px; border-radius: 8px; }
.att .native { background: #e8dcc2; } .att .love { background: rgba(110, 154, 90, .2); } .att .ok { background: rgba(110, 80, 50, .08); } .att .poor { background: rgba(217, 114, 90, .15); } .att .refuse { background: rgba(60, 60, 60, .12); text-decoration: line-through; color: var(--ink-3); }

/* minigame overlay */
.mg-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 12px; background: rgba(30, 22, 14, .55); }
.mg-frame { position: relative; width: min(760px, 100%); height: min(600px, 86svh); }
.mg-close { position: absolute; right: 6px; top: 6px; z-index: 9; background: rgba(253, 249, 240, .9); }

.toasts { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 9px 16px; border-radius: 14px; background: rgba(59, 44, 32, .92); color: #fff8ea; font-size: 14.5px; box-shadow: var(--shadow); max-width: min(90vw, 460px); animation: tin .3s ease; transition: opacity .4s, transform .4s; }
.toast.good { background: rgba(79, 116, 64, .95); } .toast.bad { background: rgba(185, 87, 63, .95); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
.dialog { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(30, 22, 14, .4); }
.dialog .paper { padding: 18px 20px; max-width: 380px; }
.dialog p { margin: 0 0 14px; line-height: 1.7; }

@media (max-width: 760px) {
  .plate { min-width: 0; max-width: calc(100% - 120px); padding: 9px 12px 8px; }
  .plate-name { font-size: 19px; }
  .plate-hint { display: none; }
  .pills { top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px); left: 10px; right: 96px; max-width: none; justify-content: flex-start; }
  .pill { height: 30px; font-size: 13px; padding-right: 9px; }
  .pill small { display: none; }
  .bell { top: max(14px, env(safe-area-inset-top)); }
  .clock { top: calc(max(14px, env(safe-area-inset-top)) + 44px); bottom: auto; left: auto; right: 14px; }
  .catch-btn { width: 66px; height: 66px; font-size: 17px; right: 14px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 58px); }
  .nav button { padding: 8px 11px; font-size: 14px; }
  .sheet, .sheet.wide { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 82%; height: 82%; border-radius: 18px 18px 0 0; animation: slideup .3s cubic-bezier(.2, .8, .2, 1); }
  @keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
  .tree { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-frame { height: min(640px, 88svh); }
}
