/* 台灣軌道建設物語 · iPhone-first city selection screen */
#screen.tw-selection {
  place-items: stretch;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: blur(10px);
}
.tw-map, .tw-map * { box-sizing: border-box; }
.tw-map {
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  padding: max(14px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px;
  color: var(--text); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
}
.tw-topbar { display:flex; align-items:center; gap:13px; max-width:1400px; width:100%; margin:0 auto; flex:0 0 auto; }
.tw-topbar h1 { margin:2px 0 0; font-size:clamp(18px, 3vw, 29px); color:var(--navy); line-height:1.3; font-weight:900; }
.tw-back { width:43px; height:43px; flex:none; border-radius:12px; border:1px solid var(--line-strong); background:var(--surface-solid); color:var(--navy); font-size:31px; line-height:1; cursor:pointer; }
.tw-beta { margin-left:auto; white-space:nowrap; font-size:11px; font-weight:800; color:var(--accent); border-radius:50px; padding:7px 10px; background:var(--surface-solid); border:1px solid var(--line-strong); }
.tw-eyebrow { font-size:11px; letter-spacing:.12em; font-weight:800; color:var(--accent); }
.tw-layout { min-height:0; width:100%; max-width:1400px; margin:0 auto; display:grid; grid-template-columns:minmax(320px,.9fr) minmax(400px,1.1fr); gap:16px; flex:1; }
.tw-detail, .tw-browser { min-width:0; min-height:0; overflow-y:auto; overscroll-behavior:contain; border:1px solid var(--line-strong); background:var(--surface-solid); border-radius:22px; box-shadow:var(--shadow-sm); padding:18px; }
.tw-detail { display:flex; flex-direction:column; gap:13px; }
.tw-hero { position:relative; height:clamp(140px,24vh,280px); min-height:135px; background:linear-gradient(120deg,#174d7e,#43a39c); overflow:hidden; border-radius:16px; flex:none; }
.tw-hero img { display:block; width:100%; height:100%; object-fit:cover; }
.tw-hero:after { content:"";position:absolute;inset:45% 0 0;background:linear-gradient(transparent,rgba(10,29,53,.6));pointer-events:none; }
.tw-hero.pending { background:linear-gradient(130deg,#1a5b8b,#88b8c9);display:grid;place-items:center; }
.tw-coming-art { font-size:76px; opacity:.75; }
.tw-hero-label { position:absolute;bottom:14px;left:16px;z-index:2;color:white;font-size:14px;font-weight:800;text-shadow:0 2px 7px rgba(0,0,0,.3); }
.tw-detail-header { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.tw-detail-header h2 { margin:5px 0 0; font-size:30px; font-weight:900; color:var(--navy); }
.tw-status { padding:7px 11px; border-radius:100px; font-size:12px; font-weight:800; background:var(--line); color:var(--muted);white-space:nowrap; }
.tw-status.ready { background:rgba(34,163,104,.12); color:#13824a; }
.tw-detail-copy p { margin:0; font-size:14px; line-height:1.7; color:var(--text); }
.tw-facts { display:flex; gap:7px; flex-wrap:wrap; margin-top:12px; }
.tw-facts span { padding:5px 9px; border-radius:7px; border:1px solid var(--line-strong); background:var(--surface);font-size:11px;color:var(--muted);font-weight:700; }
.tw-actions { display:grid; grid-template-columns:1fr 1fr; gap:9px; margin-top:auto; }
.tw-action { border-radius:12px; border:1px solid var(--line-strong);background:var(--surface);color:var(--navy); font-weight:800; font-size:14px; min-height:47px; padding:10px 12px; cursor:pointer; }
.tw-action.primary { background:var(--accent); color:white; border-color:var(--accent); }
.tw-action.subtle { background:transparent; }
.tw-action.unavailable { grid-column:1/-1; color:var(--muted);cursor:not-allowed; }
.tw-footnote {font-size:11px;line-height:1.5;color:var(--muted); }
.tw-browser {display:flex;flex-direction:column;gap:12px;}
.tw-browser-head {display:flex;align-items:baseline;justify-content:space-between;gap:8px;}
.tw-browser-head h3 {margin:0;font-size:22px;color:var(--navy);}
.tw-result-count {font-size:12px;color:var(--muted);white-space:nowrap;}
.tw-filterbar {display:flex;flex-direction:column;gap:9px;}
.tw-search {display:block;width:100%;height:42px;border:1px solid var(--line-strong); border-radius:12px;padding:0 13px;background:var(--surface);color:var(--text);outline:none;font-size:16px;}
.tw-search:focus {border-color:var(--accent);}
.tw-tabs {display:flex;gap:6px;overflow-x:auto;padding:2px 0 5px;scrollbar-width:none;}
.tw-tabs::-webkit-scrollbar {display:none;}
.tw-tab {flex:none;border:1px solid var(--line-strong);color:var(--muted);background:var(--surface);border-radius:20px;padding:8px 12px;font-size:12px;font-weight:750;cursor:pointer;}
.tw-tab.active {color:white;background:var(--accent);border-color:var(--accent);}
.tw-city-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px;align-content:start;}
.tw-city {min-width:0;min-height:81px;position:relative;display:flex;flex-direction:column;text-align:left;align-items:flex-start;justify-content:center;gap:5px;border-radius:13px;padding:12px 11px;border:1px solid var(--line-strong);background:var(--surface);color:var(--text);cursor:pointer; }
.tw-city[hidden] {display:none;}
.tw-city.selected {border-color:var(--accent);background:color-mix(in srgb,var(--accent) 9%,var(--surface-solid));box-shadow:0 0 0 1px var(--accent) inset;}
.tw-city.live {border-color:color-mix(in srgb,var(--accent) 38%,var(--line-strong));}
.tw-city-name {font-size:15px;font-weight:850;color:var(--navy);}
.tw-city-sub {font-size:10px;color:var(--muted);line-height:1.3;}
.tw-city-dot {position:absolute;right:9px;top:11px;font-size:11px;color:var(--muted);}
.tw-city-dot.live {color:#16a96c;}
.tw-browser-note {margin:4px 0 0;font-size:11px;line-height:1.5;color:var(--muted);}
#screen.start .start-title {font-size:clamp(26px,4.2vw,43px);white-space:normal;line-height:1.2;letter-spacing:.04em;}
@media (max-width:800px) {
  #screen.tw-selection {overflow-y:auto; overscroll-behavior:contain;}
  .tw-map {height:auto;min-height:100%;overflow:visible;padding: max(12px,env(safe-area-inset-top)) 12px max(16px,env(safe-area-inset-bottom));}
  .tw-layout {display:flex;flex-direction:column;flex:none;gap:12px;}
  .tw-detail,.tw-browser {overflow:visible;border-radius:17px;padding:14px;}
  .tw-hero {height:155px;min-height:155px;}
  .tw-detail {gap:10px;}
  .tw-detail-header h2 {font-size:25px;}
  .tw-detail-copy p {font-size:13px;}
  .tw-actions {margin-top:0;}
  .tw-browser-head h3 {font-size:20px;}
  .tw-city-grid {grid-template-columns:repeat(2,minmax(0,1fr));}
  .tw-city {min-height:67px;}
  .tw-beta {font-size:10px;padding:6px 8px;}
}
@media (max-width:380px) {
  .tw-topbar h1 {font-size:17px;}
  .tw-action {font-size:12px;}
  .tw-hero {height:120px;min-height:120px;}
}


/* 公司名稱輸入表單 */
.tw-company-layer {position:absolute;inset:0;z-index:100;display:grid;place-items:center;background:rgba(7,23,39,.73);padding:20px;backdrop-filter:blur(9px);}
.tw-company-dialog {width:min(460px,100%);border-radius:20px;padding:24px;display:flex;flex-direction:column;gap:14px;background:var(--surface-solid);box-shadow:0 25px 80px rgba(0,0,0,.24);color:var(--text);}
.tw-company-dialog h2 {margin:0;font-weight:900;font-size:23px;line-height:1.3;color:var(--navy);}
.tw-company-dialog p {margin:0;color:var(--muted);line-height:1.6;font-size:13px;}
.tw-company-input {height:48px;padding:0 12px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface);color:var(--text);font-size:17px;min-width:0;}
.tw-company-input:focus {outline:2px solid var(--accent);outline-offset:2px;}
.tw-company-dialog .tw-company-error {color:#c33;min-height:0;}
.tw-company-dialog .tw-actions {margin-top:0;}
/* 遊戲內公司的營收即時資訊 */
#tw-live-hud {position:fixed;z-index:45;top:calc(79px + env(safe-area-inset-top));right:calc(10px + env(safe-area-inset-right));width:min(340px,calc(100vw - 20px));display:flex;flex-direction:column;gap:5px;padding:11px 13px;border:1px solid var(--line-strong);border-radius:14px;background:color-mix(in srgb,var(--surface-solid) 95%,transparent);backdrop-filter:blur(12px);color:var(--text);box-shadow:var(--shadow-sm);pointer-events:auto;}
#tw-live-hud[hidden]{display:none!important;}
.tw-live-company {font-size:13px;font-weight:900;color:var(--navy);line-height:1.35;overflow-wrap:anywhere;}
.tw-live-numbers {font-size:11px;line-height:1.4;color:var(--muted);font-variant-numeric:tabular-nums;}
.tw-live-buttons {display:flex;gap:6px;margin-top:2px;}
.tw-live-buttons button {cursor:pointer;font-size:11px;font-weight:800;border:1px solid var(--line-strong);background:var(--surface);color:var(--text);border-radius:8px;min-height:30px;padding:5px 8px;}
/* 全臺營收排行榜 */
.tw-ranking-overlay {position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:14px;background:rgba(11,23,38,.7);backdrop-filter:blur(9px);font-family:-apple-system,BlinkMacSystemFont,'PingFang TC',sans-serif;}
.tw-ranking-card {width:min(720px,100%);max-height:calc(100dvh - 28px);display:flex;flex-direction:column;gap:10px;overflow:hidden;padding:21px;border:1px solid var(--line-strong);border-radius:19px;background:var(--surface-solid);box-shadow:0 30px 80px rgba(4,12,25,.3);color:var(--text);}
.tw-ranking-head {display:flex;justify-content:space-between;align-items:flex-start;gap:10px;}
.tw-ranking-head h2 {color:var(--navy);font-size:24px;font-weight:900;margin:4px 0 6px;line-height:1.25;}
.tw-ranking-head p {font-size:12px;line-height:1.55;color:var(--muted);margin:0;}
.tw-ranking-close {flex:none;border:1px solid var(--line-strong);border-radius:10px;width:34px;height:34px;background:var(--surface);color:var(--navy);font-size:24px;cursor:pointer;}
.tw-ranking-statusbar {display:flex;align-items:center;justify-content:space-between;gap:10px;border-top:1px solid var(--line);padding-top:10px;}
.tw-rank-status {font-size:11px;color:var(--muted);}
.tw-rank-refresh {border:1px solid var(--line-strong);border-radius:9px;background:var(--surface);padding:7px 11px;color:var(--text);font-weight:800;font-size:12px;cursor:pointer;}
.tw-rank-body {flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;}
.tw-rank-own {padding:10px 12px;border-radius:10px;border:1px solid var(--line-strong);background:var(--surface);color:var(--navy);font-size:12px;font-weight:850;margin:0 0 10px;}
.tw-rank-list {display:flex;flex-direction:column;gap:7px;}
.tw-rank-row {display:flex;align-items:center;gap:12px;min-height:63px;border:1px solid var(--line);background:var(--surface);border-radius:12px;padding:11px 12px;}
.tw-rank-place {display:grid;place-items:center;flex:none;border-radius:9px;width:34px;height:34px;font-size:15px;font-weight:900;color:var(--navy);background:var(--surface-solid);border:1px solid var(--line-strong);}
.tw-rank-detail {min-width:0;display:flex;flex:1;flex-direction:column;gap:4px;}
.tw-rank-detail b {font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.tw-rank-detail small {font-size:11px;color:var(--muted);}
.tw-rank-row strong {font-size:13px;white-space:nowrap;font-variant-numeric:tabular-nums;color:var(--navy);}
.tw-rank-empty {padding:24px 10px;text-align:center;line-height:1.7;font-size:13px;color:var(--muted);}
.tw-ranking-foot {font-size:11px;line-height:1.6;color:var(--muted);border-top:1px solid var(--line);padding-top:9px;}
@media(max-width:760px) {
  .tw-company-dialog {padding:18px;}
  #tw-live-hud {top:auto;bottom:calc(85px + env(safe-area-inset-bottom));right:calc(8px + env(safe-area-inset-right));width:min(250px,calc(100vw - 16px));padding:8px 10px;}
  .tw-live-company {font-size:11px;}
  .tw-live-numbers {font-size:10px;}
  .tw-live-buttons button {font-size:10px;min-height:29px;}
  .tw-ranking-card {padding:14px;max-height:calc(100dvh - 20px);}
  .tw-ranking-head h2 {font-size:20px;}
  .tw-rank-row {gap:8px;padding:9px 8px;}
  .tw-rank-row strong {font-size:12px;}
}


/* 遊戲首頁的 Threads 連結採用原本的選單樣式。 */
.start-btn.tw-threads-link { text-decoration: none; }
.start-btn.tw-threads-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 台灣版開發者（設定 → 關於） */
.tw-dev-profile {display:flex;align-items:center;gap:14px;padding:16px;border:1px solid var(--line-strong);border-radius:16px;background:var(--surface);flex-wrap:wrap;}
.tw-dev-avatar {width:56px;height:56px;border-radius:16px;background:linear-gradient(140deg,#2754b6,#22a77c);display:grid;place-items:center;color:white;font-size:25px;font-weight:900;flex:none;}
.tw-dev-info {min-width:0;flex:1;display:flex;flex-direction:column;gap:3px;}
.tw-dev-label {font-size:11px;color:var(--accent);letter-spacing:.1em;font-weight:800;}
.tw-dev-info strong {font-size:23px;color:var(--navy);}
.tw-dev-info p {margin:0;color:var(--muted);font-size:13px;overflow-wrap:anywhere;}
.tw-dev-link {display:inline-flex;align-items:center;justify-content:center;text-decoration:none;min-height:40px;white-space:nowrap;border-radius:10px;}
/* 公司財務報表：真實計算的模擬損益 */
.tw-finance-card {max-width:740px;}
.tw-finance-sub {color:var(--muted);font-size:12px;line-height:1.5;margin:0 0 12px;}
.tw-finance-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin:10px 0 18px;}
.tw-finance-grid>div {min-width:0;background:var(--surface);border:1px solid var(--line-strong);border-radius:12px;padding:12px;display:flex;flex-direction:column;gap:8px;}
.tw-finance-grid span {color:var(--muted);font-size:11px;font-weight:750;}
.tw-finance-grid b {font-size:clamp(13px,2.5vw,20px);color:var(--navy);overflow-wrap:anywhere;font-variant-numeric:tabular-nums;}
.tw-finance-grid b.tw-profit,.tw-profit {color:#15975f!important;}
.tw-finance-grid b.tw-loss,.tw-loss {color:#cf444f!important;}
.tw-rank-body h3 {font-size:16px;color:var(--navy);margin:15px 0 9px;}
.tw-finance-table {border:1px solid var(--line-strong);border-radius:12px;overflow:hidden;}
.tw-finance-row {display:flex;justify-content:space-between;align-items:center;gap:8px;padding:9px 12px;min-height:38px;border-bottom:1px solid var(--line);font-size:13px;}
.tw-finance-row:last-child {border-bottom:0;}
.tw-finance-row strong {font-variant-numeric:tabular-nums;white-space:nowrap;}
.tw-finance-history {margin-top:14px;}
.tw-finance-month {display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;align-items:center;font-variant-numeric:tabular-nums;padding:8px 6px;border-bottom:1px solid var(--line);font-size:12px;}
.tw-finance-month>span:nth-child(2),.tw-finance-month>strong {text-align:right;}
@media(max-width:760px){
 .tw-dev-profile {padding:12px;gap:11px;}
 .tw-dev-avatar {width:46px;height:46px;}
 .tw-dev-link {width:100%;}
 .tw-finance-grid b {font-size:13px;}
 .tw-finance-row {font-size:12px;}
 #tw-live-hud {width:min(310px,calc(100vw - 16px));}
 .tw-live-buttons {flex-wrap:wrap;}
}


/* Private cloud login, account, and safe save selection (iPhone Safari). */
.tw-account-overlay {position:fixed;inset:0;z-index:1500;display:grid;place-items:center;padding:14px;background:rgba(9,25,44,.76);backdrop-filter:blur(10px);font-family:-apple-system,BlinkMacSystemFont,'PingFang TC',sans-serif}
.tw-account-card {display:flex;flex-direction:column;gap:12px;width:min(580px,100%);max-height:calc(100dvh - 25px);overflow:hidden;padding:20px;border-radius:19px;background:var(--surface-solid);border:1px solid var(--line-strong);box-shadow:0 20px 80px rgba(0,0,0,.32);color:var(--text)}
.tw-account-head {display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.tw-account-head h2 {margin:4px 0 0;font-weight:900;font-size:23px;color:var(--navy)}
.tw-account-close {flex:none;width:35px;height:35px;border-radius:10px;border:1px solid var(--line-strong);background:var(--surface);color:var(--navy);font-size:24px;cursor:pointer}
.tw-account-body {display:flex;flex-direction:column;gap:10px;overflow-y:auto;overscroll-behavior:contain;min-height:0;padding:2px 2px 8px}
.tw-account-body h3 {font-size:15px;margin:8px 0 0;color:var(--navy)}
.tw-account-body label {font-size:12px;font-weight:850;color:var(--navy);margin-top:4px}
.tw-account-body input {display:block;width:100%;height:46px;border:1px solid var(--line-strong);border-radius:12px;padding:10px 13px;font-size:16px;color:var(--text);background:var(--surface)}
.tw-account-body input:focus {outline:2px solid var(--accent);outline-offset:1px}
.tw-account-btn {min-height:42px;padding:9px 14px;text-align:center;border:1px solid var(--line-strong);border-radius:11px;background:var(--surface);color:var(--navy);font-size:13px;font-weight:850;cursor:pointer}
.tw-account-btn.primary {background:var(--accent);color:white;border-color:var(--accent)}
.tw-account-btn.danger {background:#a62a38;border-color:#a62a38;color:white}
.tw-account-btn:disabled {opacity:.53;cursor:not-allowed}
.tw-account-note {font-size:12px;color:var(--muted);line-height:1.55;margin:2px 0}
.tw-account-status {font-size:12px;color:var(--text);line-height:1.5;min-height:13px;margin:2px 0}
.tw-account-actions {display:grid;grid-template-columns:1fr 1fr;gap:9px}
.tw-account-saves {display:flex;flex-direction:column;gap:9px}
.tw-account-save {min-width:0;display:flex;align-items:center;justify-content:space-between;gap:10px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface);padding:10px}
.tw-account-save-info {min-width:0;flex:1;display:flex;flex-direction:column;gap:4px}
.tw-account-save-info b {color:var(--navy);font-size:13px;line-height:1.35;overflow-wrap:anywhere}
.tw-account-save-info span,.tw-account-save-info small {color:var(--muted);font-size:11px;line-height:1.3}
.tw-account-save .tw-account-btn {min-height:35px;flex:none;font-size:11px;white-space:nowrap;padding:8px 11px}
.tw-bankrupt-screen {background:rgba(5,17,28,.83)}
.tw-bankrupt-card {width:min(510px,calc(100vw - 26px));max-height:calc(100dvh - 30px);overflow-y:auto;display:flex;flex-direction:column;gap:13px;padding:25px;border-radius:20px;border:1px solid var(--line-strong);background:var(--surface-solid);color:var(--text);box-shadow:0 30px 80px rgba(0,0,0,.35)}
.tw-bankrupt-symbol {font-size:39px}
.tw-bankrupt-card h2 {margin:0;color:#ba303a;font-size:30px;font-weight:900}
.tw-bankrupt-card>p {margin:0;font-size:13px;line-height:1.65;color:var(--text)}
.tw-bankrupt-report {display:grid;grid-template-columns:1fr 1fr;gap:9px}
.tw-bankrupt-report>div {border:1px solid var(--line-strong);background:var(--surface);border-radius:12px;padding:12px;display:flex;flex-direction:column;gap:6px}
.tw-bankrupt-report span {font-size:11px;color:var(--muted)}
.tw-bankrupt-report strong {font-size:15px;color:var(--navy);font-variant-numeric:tabular-nums}
.tw-bankrupt-reasons {padding:10px 12px;background:var(--surface);border-radius:10px}
.tw-bankrupt-reasons p {font-size:12px;margin:6px 0;color:#bb3942;line-height:1.45}
.tw-bankrupt-card .tw-bankrupt-note {color:var(--muted);font-size:11px}
.tw-bankrupt-actions {display:grid;grid-template-columns:1fr 1fr;gap:9px}
@media (max-width:500px){.tw-account-card{padding:15px}.tw-account-head h2{font-size:20px}.tw-account-save {flex-wrap:wrap}.tw-account-save .tw-account-btn {width:100%}.tw-bankrupt-card {padding:18px}.tw-bankrupt-card h2{font-size:25px}.tw-bankrupt-actions{grid-template-columns:1fr}}


/* 地圖操作優先：排行榜／財務／公司名稱已搬進遊戲左上角原生選單。 */
#tw-live-hud { display: none !important; }
.dropdown .tw-dropdown-stats {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  border-radius: 9px; padding: 10px 12px; margin: 3px 6px 7px;
  background: var(--surface); border: 1px solid var(--line-strong);
}
.dropdown .tw-dropdown-stats strong {
  color: var(--navy); font-size: 12px; font-weight: 850;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
}
.dropdown .tw-dropdown-stats span {
  color: var(--muted); font-size: 11px; line-height: 1.5;
  white-space: normal;
}
.dropdown button.tw-menu-action { min-height: 41px; }
.dropdown .tw-menu-symbol { width: 20px; flex: none; text-align: center; font-size: 14px; }
@media (pointer: coarse) {
  .dropdown button.tw-menu-action { min-height: 46px; }
}

/* 地震警報使用遊戲原生卡片、圖示、字體與主題色，而不是獨立的 emoji 式全螢幕樣式。 */
.tw-quake-mask{background:rgba(10,18,32,.72);backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px)}
.tw-quake-alert{background:var(--surface-solid,#fdfdfd);color:var(--text,#152233);
 border:1px solid var(--line-strong,#bac6d1);border-top:5px solid var(--accent,#ca782b);
 border-radius:16px;box-shadow:0 20px 70px rgba(0,0,0,.3);font-family:inherit}
.tw-quake-alert h2{display:flex;align-items:center;justify-content:center;gap:10px;color:var(--navy,#263a53);font-size:24px}
.tw-quake-alert h2 .ico{display:inline-flex;color:var(--accent,#ca782b)}
.tw-quake-alert p{color:var(--text,#152233)}
.tw-quake-intensity{color:var(--navy,#263a53);font-size:22px}
.tw-quake-notreal{background:var(--accent-soft,#fff1d2);color:var(--navy,#263a53);
 border:1px solid var(--line-strong,#bac6d1);font-weight:700}
.tw-quake-seconds{color:var(--navy,#263a53);font-size:40px}
.tw-quake-alert .btn:disabled{opacity:.48}
@media(max-width:480px){.tw-quake-alert h2{font-size:21px}}
