* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #2a1e2a; color: #f4ead8; font-family: Georgia, 'Times New Roman', serif; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#cv { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- in flight */
.hud { position: absolute; inset: 0; pointer-events: none; }
.crew { position: absolute; left: max(8px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 4px; }
.badge { position: relative; display: flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px 0 5px; background: rgba(30,20,24,0.55); border-radius: 11px; font-size: 12px; width: max-content; transition: background .2s; }
.badge i { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.5) inset; }
.badge b { font-weight: normal; min-width: 34px; }
.badge .hp { width: 42px; height: 4px; background: rgba(255,255,255,0.18); border-radius: 2px; overflow: hidden; }
.badge .hp span { display: block; height: 100%; width: 100%; background: #e8d090; transition: width .25s; }
.badge.low .hp span { background: #e8603a; }
.badge.trouble { background: rgba(170,40,30,0.75); animation: pulse .5s infinite alternate; }
.badge.down { opacity: .45; }
.badge.down b { text-decoration: line-through; }
.badge .say { position: absolute; left: calc(100% + 6px); top: -2px; font-style: normal; background: rgba(250,240,220,0.94); color: #2a1a12; padding: 4px 9px; border-radius: 10px; font-size: 13px; line-height: 1.25; width: max-content; max-width: min(calc(100vw - 170px), 380px); opacity: 0; transform: translateX(-6px); transition: opacity .2s, transform .2s; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.badge .say::before { content: ''; position: absolute; left: -5px; top: 9px; border: 5px solid transparent; border-left: 0; border-right-color: rgba(250,240,220,0.94); }
.badge.talking .say { opacity: 1; transform: none; }
@keyframes pulse { to { background: rgba(220,60,40,0.9); } }
.topr { position: absolute; right: max(8px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); }
.pause { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(30,20,24,0.55); color: #f4ead8; display: grid; place-items: center; }
.pause svg { width: 18px; height: 18px; }
.obj { position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); font-size: 13px; background: rgba(30,20,24,0.55); padding: 5px 11px; border-radius: 10px; max-width: 60vw; }
.obj:empty { display: none; }
.special { pointer-events: auto; position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 74px; height: 74px; border-radius: 50%; border: 3px solid rgba(255,235,190,0.7); background: rgba(120,40,30,0.72); color: #fff3d8; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.35); touch-action: none; }
.special .ic svg { width: 28px; height: 28px; display: block; }
.special .n { position: absolute; right: -2px; top: -2px; background: #f4ead8; color: #3a1a12; border-radius: 10px; font-size: 13px; padding: 1px 6px; font-weight: bold; }
.special:active { transform: scale(.93); }
.special.empty { opacity: .35; }
.banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; opacity: 0; transform: scale(.9); transition: opacity .25s, transform .25s; text-shadow: 0 2px 10px rgba(0,0,0,.6), 0 0 2px rgba(0,0,0,.8); }
.banner div { font-size: clamp(26px, 8vw, 54px); font-weight: bold; letter-spacing: .02em; }
.banner small { display: block; font-size: 15px; margin-top: 4px; }
.banner.show { opacity: 1; transform: none; }
.banner.contact div { font-size: clamp(40px, 14vw, 90px); font-style: italic; color: #fff0c8; }
.banner.good div { color: #ffe08a; }
.banner.bad div { color: #ffb090; }
.hint { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: rgba(30,20,24,0.7); padding: 10px 16px; border-radius: 12px; font-size: 15px; text-align: center; width: max-content; max-width: 86vw; line-height: 1.4; animation: hintIn .5s; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- paper screens */
.panel { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); overflow-y: auto; }
.panel.pause, .panel.result, .panel.brief, .panel.board, .panel.hangar { background: rgba(20,12,16,0.45); align-items: center; }
.paper { width: 100%; max-width: 460px; background: #efe3c8; color: #2a1a12; border-radius: 4px; padding: 18px 18px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.5), inset 0 0 40px rgba(140,100,50,.25); max-height: 100%; overflow-y: auto; }
.paper h1 { font-size: 46px; font-style: italic; letter-spacing: .01em; color: #8a2a1e; }
.paper h2 { font-size: 26px; color: #6a2418; margin-bottom: 8px; }
.paper p { margin: 6px 0; line-height: 1.4; }
.paper .sub { font-size: 15px; color: #5a3a24; }
.paper .small { font-size: 13px; color: #5a4a3a; }
.paper .big { font-size: 22px; font-weight: bold; color: #6a4a10; }
.paper .loss { color: #8a2418; font-weight: bold; }
.paper .gold { color: #8a6a10; font-weight: bold; }
.paper .who { font-style: italic; color: #5a4a3a; font-size: 14px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.btns button { flex: 1 1 auto; min-height: 46px; padding: 8px 14px; font-size: 16px; border: 2px solid #8a6a4a; border-radius: 4px; background: #f8f0dc; color: #3a2416; }
.btns button.big { background: #8a2a1e; color: #fff3dc; border-color: #6a1a10; font-size: 18px; font-weight: bold; }
.btns button:active { transform: scale(.97); }
.panel.title { align-items: flex-end; }
.panel.title .paper { background: rgba(239,227,200,0.94); }
.cards { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.card { text-align: left; background: #f8f0dc; border: 2px solid #8a6a4a; border-radius: 4px; padding: 10px 12px; color: #2a1a12; font-size: 14px; line-height: 1.4; display: flex; flex-direction: column; gap: 4px; }
.card b { font-size: 19px; color: #6a2418; }
.card em { color: #8a2418; font-size: 13px; }
.card small { color: #6a5a40; font-size: 12px; }
.card:active { background: #fff8e4; }
.panel.talk { align-items: flex-end; }
.panel.talk .paper, .panel.hub .paper { background: rgba(239,227,200,0.95); }
.line b { font-size: 15px; text-shadow: 0 0 1px rgba(0,0,0,.5); filter: brightness(.7); }
.line p { font-size: 18px; margin-top: 2px; }
.tap { text-align: right; font-size: 12px; color: #8a7a60; font-style: italic; }
.panel.board table { width: 100%; border-collapse: collapse; font-size: 15px; }
.panel.board td { padding: 5px 4px; border-bottom: 1px solid rgba(90,60,30,.2); }
.panel.board td.tally { font-family: monospace; letter-spacing: 1px; color: #3a2a1a; }
.panel.board td.tally s { text-decoration: line-through; margin-right: 4px; }
.panel.board tr.dead { color: #8a7a6a; text-decoration: line-through; }
.panel.hangar { align-items: flex-end; background: transparent; }
.ups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.up { background: #f8f0dc; border: 1px solid #c8b090; border-radius: 4px; padding: 7px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.up b { font-size: 14px; color: #6a2418; }
.up span { color: #5a4a3a; }
.up button { border: 2px solid #8a6a4a; background: #fff; border-radius: 4px; padding: 5px; text-align: left; font-size: 13px; color: #2a1a12; display: flex; flex-direction: column; }
.up button small { color: #6a5a40; font-size: 11px; }
.up button i { color: #8a2a1e; font-style: normal; font-weight: bold; }
.up button:disabled { opacity: .45; }
.up em { color: #6a8a40; }
.panel.hangar .paper { max-height: 60vh; background: rgba(239,227,200,0.96); padding: 12px 12px 10px; }
.panel.hangar h2 { font-size: 20px; margin: 0; }
.panel.hangar .line p { font-size: 15px; }
.up { padding: 5px; }
.up button { padding: 4px 5px; }
.panel.result.won h2 { color: #8a6a10; }
@media (orientation: landscape) and (max-height: 500px) {
  .paper { max-width: 640px; padding: 12px 14px 10px; }
  .paper h1 { font-size: 34px; }
  .cards { flex-direction: row; }
  .card { flex: 1; }
  .ups { grid-template-columns: 1fr 1fr 1fr; }
  .panel.hangar .paper { max-height: 92vh; }
  .badge .say { max-width: 46vw; }
}
.gohome { pointer-events: auto; position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); min-height: 50px; padding: 0 20px; border-radius: 25px; border: 2px solid rgba(255,235,190,0.8); background: rgba(40,70,40,0.8); color: #fff3d8; font-size: 17px; animation: hintIn .4s; }
.paper h2 .date { display: block; font-size: 14px; font-weight: normal; color: #6a5a40; font-style: italic; }
