/* Founders-Sim · planet edition of My AI Startup (Cobalt palette) */
:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, .94);
  --surface-solid: #fff;
  --border: #e3e9f2;
  --text: #172b4d;
  --muted: #66758d;
  --blue: #315fe9;
  --blue-dark: #2449bd;
  --blue-soft: #edf2ff;
  --red: #d75770;
  --gold: #a0700a;
  --green: #189b91;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(23, 43, 77, .12);
  --font: 'Avenir Next', Inter, 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; touch-action: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface-solid); border-radius: 11px; padding: 9px 14px; font-weight: 600; transition: background .15s, border-color .15s, transform .15s, box-shadow .15s; }
button:hover:not(:disabled) { border-color: #c5d3ea; background: #f7f9fd; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
button.link { border: 0; background: none; color: var(--blue); padding: 4px 0; }
:focus-visible { outline: 3px solid #7899ff; outline-offset: 2px; }
input, select { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 9px 11px; }
input:focus, select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(49, 95, 233, .15); }
h1, h2, h3, p { margin: 0; }
kbd { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 7px; border-radius: 8px; border: 1px solid #cfd9ea; border-bottom-width: 3px; background: #fff; font: 700 12px/1 var(--font); color: var(--text); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.gold { color: var(--gold); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
#globe, #map { position: fixed; inset: 0; display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.screen { position: fixed; inset: 0; overflow-y: auto; padding: 24px 16px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }

/* Home */
#home { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 380px); gap: 18px; justify-content: center; align-content: center; }
.hero { padding: 28px; display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--blue); }
.brand img { border-radius: 8px; }
h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.02; letter-spacing: -1.6px; }
.lede { font-size: 16px; color: #33476a; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields .wide { grid-column: 1 / -1; }
select:disabled { color: var(--muted); background: #f6f8fc; }
label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.cta .primary { flex: 1 1 200px; padding: 12px 18px; font-size: 15px; }
.cta button:not(.primary) { flex: 1 1 180px; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.error { color: #b5424e; min-height: 1.5em; font-weight: 600; }
.rules { padding: 20px; display: grid; gap: 12px; align-content: start; }
.rule { display: grid; grid-template-columns: 62px 1fr; gap: 12px; align-items: start; }
.rule kbd { justify-self: start; }
.credits { grid-column: 1 / -1; text-align: center; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .7); border-radius: 10px; padding: 6px 10px; justify-self: center; }

/* Lobby */
#lobby { display: grid; place-items: center; }
.lobby-card { width: min(520px, 100%); padding: 26px; display: grid; gap: 14px; }
#lobby-code { font-size: 46px; letter-spacing: .18em; font-weight: 800; color: var(--blue); }
.share { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.roster li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.roster i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.roster .tags { margin-left: auto; display: flex; gap: 4px; }
.roster .tag { font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.roster .tag.you { color: var(--blue); border-color: #c7d5fb; background: var(--blue-soft); }
.roster .out { opacity: .5; text-decoration: line-through; }
.host-tools { display: flex; gap: 12px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 36px; padding: 6px 0; }
.stepper output { min-width: 22px; text-align: center; font-size: 18px; font-weight: 700; color: var(--text); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.panel { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.company { top: 14px; left: 14px; width: 270px; padding: 13px 15px; display: grid; gap: 6px; }
.company-head { display: flex; align-items: center; gap: 8px; }
.company-head i { width: 12px; height: 12px; border-radius: 50%; }
.stage { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--gold); background: #fff7e6; border: 1px solid #f1dcae; border-radius: 999px; padding: 1px 9px; }
.team-line { display: flex; align-items: baseline; gap: 7px; }
.team-line strong { font-size: 28px; line-height: 1; letter-spacing: -1px; }
.bar { height: 7px; border-radius: 99px; background: #e8eef8; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #6b8cff); border-radius: inherit; transition: width .25s; }
.bar.full i { background: linear-gradient(90deg, #d98449, #d75770); }
.bar.thin { height: 5px; }
.money { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.money strong { color: var(--text); }
.strength { display: flex; align-items: baseline; gap: 7px; font-size: 13px; color: var(--muted); }
.strength strong { color: var(--text); font-size: 16px; }
.next { font-size: 12px; color: var(--muted); }
.roles { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); }
.roles span { display: inline-flex; align-items: center; gap: 4px; }
.roles i { width: 8px; height: 8px; border-radius: 2px; }
.clock { top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 16px; min-width: 210px; text-align: center; display: grid; gap: 4px; font-weight: 600; }
.planet-name { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.side { top: 14px; right: 14px; width: 250px; padding: 10px 12px; display: grid; gap: 7px; max-height: calc(100% - 120px); overflow: auto; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.side .small { text-transform: none; letter-spacing: 0; font-weight: 500; }
#minimap { width: 100%; display: block; }
.roster.compact li { padding: 4px 8px; font-size: 13px; }
.news { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 12px; }
.news li { padding: 5px 8px; border-radius: 8px; background: #f6f8fc; border-left: 3px solid var(--border); }
.news li b { font-weight: 700; }
.menu { position: absolute; bottom: 16px; right: 14px; display: flex; gap: 8px; }
.menu button { background: var(--surface); box-shadow: var(--shadow); }
.actions { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.action { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; min-width: 170px; padding: 10px 14px; border-radius: 14px; box-shadow: var(--shadow); background: var(--surface-solid); text-align: left; }
.action span { display: grid; line-height: 1.2; }
.action small { font-weight: 500; color: var(--muted); font-size: 12px; }
.action .cool { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--blue); }
.action.blocked small { color: #b5424e; }
.action.flash { box-shadow: 0 0 0 3px rgba(49, 95, 233, .35), var(--shadow); }
.action.auto { min-width: 150px; }
.action.on { background: var(--blue-soft); border-color: #9fb6f7; box-shadow: 0 0 0 3px rgba(49, 95, 233, .2), var(--shadow); }
.action.on:hover:not(:disabled) { background: #e3eaff; border-color: #9fb6f7; }
.action.on kbd { background: var(--blue); border-color: var(--blue-dark); color: #fff; }
.action.on small { color: var(--blue); font-weight: 600; }
.persona { position: absolute; width: 250px; padding: 11px 13px; font-size: 12px; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); pointer-events: none; display: grid; gap: 3px; }
.persona .who { font-size: 14px; font-weight: 700; }
.persona .odds { display: flex; gap: 12px; margin-top: 3px; }
.persona .odds b { font-size: 15px; }
.persona .match { color: var(--blue); font-weight: 700; }
.toasts { position: absolute; left: 14px; bottom: 18px; width: min(330px, calc(100% - 28px)); display: grid; gap: 6px; pointer-events: none; }
.toast { background: var(--surface-solid); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 10px; padding: 8px 11px; box-shadow: var(--shadow); font-size: 13px; animation: rise .25s ease-out; }
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast.gold { border-left-color: #c8961e; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.warning { position: absolute; top: 124px; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; background: #fff0f2; color: #9c2f45; border: 1px solid #f3c3cd; font-weight: 700; box-shadow: var(--shadow); }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: var(--blue); text-shadow: 0 6px 30px rgba(49, 95, 233, .3); pointer-events: none; }
.coach { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); width: min(460px, calc(100% - 28px)); background: #172b4d; color: #fff; border-radius: 14px; padding: 13px 15px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.coach p { flex: 1 1 260px; }
.coach button { background: #fff; color: var(--text); border: 0; padding: 6px 12px; }
.coach .link { background: none; color: #b8c8f5; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(236, 241, 250, .55); padding: 16px; }
.overlay .card { width: min(440px, 100%); padding: 24px; display: grid; gap: 12px; }
.overlay .card:has(.versus) { width: min(520px, 100%); }
.out-label { color: var(--red); }
.contest { position: absolute; top: calc(var(--company-bottom, 216px) + 12px); left: 14px; width: min(400px, calc(100% - 28px)); max-height: calc(100% - var(--company-bottom, 216px) - 112px); overflow: auto; padding: 12px 14px; display: grid; gap: 6px; z-index: 2; }
.contest-head { display: flex; justify-content: space-between; align-items: center; }
.contest h3 { font-size: 18px; }
.versus { width: 100%; border-collapse: collapse; font-size: 13px; }
.versus th, .versus td { padding: 5px 8px; border-bottom: 1px solid #eef2f8; text-align: right; white-space: nowrap; }
.versus th:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.versus thead th { font-size: 13px; color: var(--text); font-weight: 700; vertical-align: bottom; }
.versus thead small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.versus thead .win small { color: var(--green); }
.versus thead .lose small { color: var(--red); }
.versus td:nth-child(2) { background: rgba(24, 155, 145, .07); }
.versus tr.total td, .versus tr.total th { font-size: 15px; color: var(--text); border-top: 2px solid var(--border); }
.versus i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.versus .you { font-size: 10px; color: var(--blue); border: 1px solid #c7d5fb; background: var(--blue-soft); border-radius: 999px; padding: 0 5px; }
.formula { font-size: 12px; color: var(--muted); line-height: 1.5; }
.formula b { color: var(--text); }
.badge.out { color: #9c2f45; border-color: #f3c3cd; }
.stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(49, 95, 233, .35); background: rgba(255, 255, 255, .35); pointer-events: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(49, 95, 233, .55); }

/* Results */
#results { display: grid; place-items: center; background: rgba(236, 241, 250, .45); }
.results-card { width: min(760px, 100%); padding: 26px; display: grid; gap: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid #eef2f8; white-space: nowrap; }
td i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
tr.me td { background: var(--blue-soft); font-weight: 700; }
.badge { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 6px; }

/* Rules dialog */
dialog { border: 0; border-radius: 18px; padding: 0; max-width: min(640px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(23, 43, 77, .3); color: var(--text); }
dialog::backdrop { background: rgba(23, 43, 77, .35); }
.rules-dialog { padding: 24px 26px; display: grid; gap: 12px; max-height: 85vh; overflow: auto; }
.rules-dialog ol { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.rules-dialog .primary { justify-self: end; }

@media (max-width: 1180px) {
  .action, .action.auto { min-width: 0; }
}
@media (max-width: 980px) {
  #home { grid-template-columns: minmax(0, 560px); align-content: start; }
  .rules { display: none; }
  .side { width: 200px; }
  .side .news, .side h3:last-of-type { display: none; }
}
@media (max-width: 680px) {
  .screen { padding: 14px; }
  .hero { padding: 20px; }
  .fields { grid-template-columns: 1fr 1fr; }
  .company { width: auto; right: 14px; padding: 9px 12px; gap: 4px; }
  .company .roles, .company .next { display: none; }
  .team-line strong { font-size: 22px; }
  .clock { top: auto; bottom: 86px; left: 14px; transform: none; min-width: 0; padding: 5px 10px; font-size: 12px; }
  .planet-name { display: none; }
  .warning { top: calc(var(--company-bottom, 150px) + 56px); }
  .side { top: auto; bottom: 86px; right: 14px; width: 132px; padding: 6px; }
  .side h3, .side .roster { display: none; }
  .actions { left: auto; right: 12px; transform: none; bottom: 14px; gap: 8px; }
  .action { min-width: 0; padding: 9px 11px; }
  .action small { display: none; }
  .menu { bottom: auto; top: calc(var(--company-bottom, 150px) + 8px); right: 14px; }
  .toasts { bottom: 150px; }
  .coach { bottom: 150px; padding: 10px 12px; font-size: 13px; }
  .contest { top: calc(var(--company-bottom, 150px) + 56px); max-height: calc(100% - var(--company-bottom, 150px) - 214px); }
  .coach p { flex-basis: 100%; }
  .persona { display: none !important; }
  .countdown { font-size: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
