/* 80s office amber look */
:root {
  --wood: #5a3d2b;
  --wood-dark: #4a3123;
  --panel: #2e2620;
  --amber: #ffb454;
  --amber-dim: #c78a3a;
  --paper: #e8dcc0;
  --paper-dark: #cdbfa0;
  --green: #7bc96f;
  --red: #e63946;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #1a120c;
  color: var(--paper);
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }

/* ---------- shared ---------- */
h1, h2, h3 { margin: 0.2em 0; }
h3 small { font-size: 0.55em; font-weight: normal; color: var(--paper-dark); }
button {
  font-family: inherit; cursor: pointer;
  background: var(--amber); color: #241a0d; border: none;
  padding: 8px 16px; font-size: 14px; font-weight: bold;
  border-radius: 3px; box-shadow: 0 2px 0 #7a5a2a;
}
button:hover { filter: brightness(1.1); }
button:disabled { background: #6b5a3f; color: #2a2214; cursor: not-allowed; opacity: 0.75; }
button.ghost { background: transparent; color: var(--paper); box-shadow: none; border: 1px solid var(--amber-dim); }
button.ghost:disabled { opacity: 0.3; color: var(--paper-dark); }
.tag { color: var(--amber-dim); }
.flash { animation: flash 0.6s infinite alternate; }
@keyframes flash { from { color: var(--amber); } to { color: var(--red); } }

/* ---------- setup screen ---------- */
.setup {
  max-width: 720px; margin: 0 auto; padding: 32px 24px; height: 100%;
  display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.setup .logo {
  text-align: center; padding: 18px 0 6px;
}
.setup .logo .big {
  font-size: 42px; letter-spacing: 4px; color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 180, 84, 0.45);
}
.setup .logo .sub { color: var(--paper-dark); font-size: 14px; letter-spacing: 2px; }
.player-card {
  border: 2px solid var(--amber-dim); border-radius: 6px;
  padding: 10px 14px; display: flex; align-items: center; gap: 14px;
  background: rgba(255, 180, 84, 0.06);
}
.player-card.off { opacity: 0.45; }
.player-card .swatch { width: 26px; height: 26px; border-radius: 4px; flex: none; }
.player-card input[type=text] {
  flex: 1; background: var(--panel); color: var(--paper);
  border: 1px solid var(--amber-dim); padding: 6px 10px; font-family: inherit; font-size: 15px;
}
.player-card select { background: var(--panel); color: var(--paper); border: 1px solid var(--amber-dim); font-family: inherit; padding: 5px; }
.setup-goals { display: flex; gap: 10px; flex-wrap: wrap; }
.goal {
  border: 2px solid var(--amber-dim); border-radius: 6px; padding: 10px 14px;
  cursor: pointer; min-width: 150px; background: rgba(255,180,84,0.05);
}
.goal.sel { border-color: var(--amber); background: rgba(255,180,84,0.18); }
.goal b { color: var(--amber); display: block; margin-bottom: 4px; }
.goal small { color: var(--paper-dark); }
.setup .foot { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.setup .foot input { width: 110px; background: var(--panel); color: var(--paper); border: 1px solid var(--amber-dim); padding: 6px; font-family: inherit; }
.disclaimer { color: #8a7a5f; font-size: 11px; margin-top: auto; }

/* ---------- office hub ---------- */
.hud {
  display: flex; align-items: center; gap: 18px; padding: 6px 14px;
  background: var(--wood-dark); border-bottom: 3px solid #2c1d13;
}
.hud .cal { font-size: 20px; font-weight: bold; color: var(--amber); cursor: pointer; }
.hud .players { display: flex; gap: 10px; margin-left: auto; }
.hud .pl { display: flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; opacity: 0.6; }
.hud .pl.active { opacity: 1; outline: 2px solid var(--amber); }
.hud .pl .dot { width: 12px; height: 12px; border-radius: 2px; }
.hud .pl.ai-tag { font-size: 10px; color: var(--paper-dark); }
.office {
  flex: 1; display: flex; gap: 10px; padding: 10px 14px; align-items: stretch; min-height: 0;
}
.col {
  display: flex; flex-direction: column; gap: 10px; width: 190px; flex: none;
}
.desk-item {
  flex: 1; border: 3px solid var(--wood); border-radius: 8px;
  background: linear-gradient(160deg, var(--wood) 0%, var(--wood-dark) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; gap: 6px; user-select: none; min-height: 90px;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.4);
}
.desk-item:hover { border-color: var(--amber); }
.desk-item .icon { font-size: 40px; }
.desk-item .label { font-size: 13px; color: var(--paper); letter-spacing: 1px; }
.desk-item.notify .label { color: var(--red); animation: blink 0.8s infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: 0.35; } }
.stage {
  flex: 1; background: radial-gradient(ellipse at 50% 30%, #4d3826 0%, #2b1d12 70%);
  border: 3px solid var(--wood); border-radius: 10px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-width: 0; padding: 16px; overflow: hidden;
}
.stage h2 { color: var(--amber); letter-spacing: 2px; }
.stage .scene { font-size: 100px; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6)); }
.logbox {
  align-self: stretch;      /* normal flow: sits BELOW the end-turn button */
  margin-top: auto;         /* pinned to the stage bottom when space allows */
  max-height: 30%;
  overflow-y: auto;
  font-size: 11.5px;
  color: var(--paper-dark);
  background: rgba(0,0,0,0.35);
  border-radius: 6px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.logbox div { margin: 1px 0; }
.turn-btn { font-size: 18px; padding: 12px 30px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 3px solid var(--amber-dim); border-radius: 8px;
  width: min(860px, 94vw); max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}
.modal-head {
  display: flex; align-items: center; padding: 10px 16px;
  border-bottom: 2px solid var(--amber-dim); color: var(--amber);
}
.modal-head h2 { font-size: 18px; letter-spacing: 2px; margin: 0; }
.modal-head .x { margin-left: auto; cursor: pointer; font-size: 20px; color: var(--paper-dark); }
.modal-head .x:hover { color: var(--red); }
.modal-body { padding: 14px 16px; overflow-y: auto; }

/* world map */
.worldmap { position: relative; width: 100%; aspect-ratio: 2 / 1; background: #12314a; border-radius: 6px; overflow: hidden; }
.worldmap .continent { position: absolute; background: #2f6b4f; border-radius: 40% 60% 55% 45% / 50% 45% 60% 50%; opacity: 0.9; }
.worldmap .region {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(255,180,84,0.92); color: #241a0d; font-weight: bold;
  border: 2px solid #241a0d; border-radius: 5px; padding: 4px 8px; font-size: 12px;
  cursor: pointer; white-space: nowrap;
}
.worldmap .region:hover { background: #fff; }
.worldmap .region.mine { background: var(--green); }
.worldmap .region.owned { background: var(--red); color: #fff; cursor: not-allowed; }

/* tables & lists */
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; color: var(--amber-dim); border-bottom: 1px solid var(--amber-dim); padding: 4px 8px; }
table.list td { padding: 5px 8px; border-bottom: 1px solid #3a3128; }
table.list tr.clickable:hover { background: rgba(255,180,84,0.12); cursor: pointer; }
table.list tr.sel { background: rgba(255,180,84,0.2); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: bold; }
.badge.free { background: #2b4a2f; color: #9fd98f; }
.badge.mine { background: #2f4a5a; color: #9fd0ff; }
.badge.rival { background: #4a2b2b; color: #ff9f9f; }
.badge.fire { background: var(--red); color: #fff; }
.badge.dud { background: #55442a; color: #d8b96a; }
.badge.rock { background: #3a3a4a; color: #b8b8d8; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type="range"] { accent-color: var(--amber); height: 22px; }
.spacer { flex: 1; }
.panel-box { border: 1px solid #4a3d2e; border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; background: rgba(0,0,0,0.2); }
.hint { color: var(--paper-dark); font-size: 12px; }

/* newspaper */
.news-item { border-left: 3px solid var(--amber-dim); padding: 4px 12px; margin: 8px 0; }
.news-item .date { color: var(--amber-dim); font-size: 11px; }

/* minigame */
.mg-wrap { text-align: center; }
.mg-wrap canvas {
  background: #000; border: 3px solid var(--amber-dim); border-radius: 6px;
  max-width: 100%; touch-action: none;
  display: block; margin: 0 auto;   /* JS sets the exact responsive size */
}
@media (max-width: 640px) {
  .mg-wrap { padding: 0 2px; }
  .mg-note { font-size: 11px; }
  .mg-btn { min-width: 96px; min-height: 52px; font-size: 15px; padding: 12px 18px; }
}
.mg-note { color: var(--paper-dark); font-size: 12px; margin-top: 6px; }
.mg-controls { display: flex; gap: 12px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.mg-btn {
  font-family: inherit; font-size: 17px; font-weight: bold; letter-spacing: 1px;
  padding: 16px 26px; min-width: 120px; min-height: 56px;
  background: var(--panel); color: var(--paper);
  border: 2px solid var(--amber-dim); border-radius: 8px; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.mg-btn:active { background: rgba(255,180,84,0.25); border-color: var(--amber); }
.mg-btn.danger { border-color: var(--red); color: #ff9f9f; }
.mg-btn.danger:active { background: rgba(230,57,70,0.3); }

/* tablets & phones */
@media (pointer: coarse) {
  button, .desk-item, .worldmap .region, table.list button, select, input[type="range"] {
    touch-action: manipulation; /* kill 300 ms double-tap zoom delays */
  }
  button { min-height: 44px; }
  table.list button { padding: 10px 16px; }
  .col { width: 132px; }
  .desk-item { min-height: 72px; }
  .desk-item .icon { font-size: 32px; }
  .desk-item .label { font-size: 11px; }
  .hud { flex-wrap: wrap; row-gap: 4px; }
  .hud .cal { font-size: 16px; }
  .hud .players { width: 100%; margin-left: 0; justify-content: center; flex-wrap: wrap; gap: 4px; }
  .hud .pl .tag { display: none; }
  .modal { width: 96vw; max-height: 94vh; }
  .modal-body { padding: 10px 12px; }
  .modal-head h2 { font-size: 15px; }
  .worldmap .region { font-size: 10px; padding: 3px 6px; border-width: 1.5px; }
  #mute-btn { font-size: 24px; padding: 10px 14px; }
  .handover-name { font-size: 30px; }
  .handover-box { padding: 30px 24px; margin: 0 12px; }
  #toast { font-size: 14px; }
}

/* portrait tablet: minigames want landscape */
@media (pointer: coarse) and (orientation: portrait) {
  .mg-wrap::before {
    content: "↻ Bitte ins Querformat drehen";
    display: block; color: var(--amber); font-weight: bold;
    margin-bottom: 8px; font-size: 14px;
  }
}

/* sound toggle (fixed, bottom right of the office) */
.hud-btn {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  background: var(--panel); color: var(--paper);
  border: 1px solid var(--amber-dim); border-radius: 6px;
  font-size: 20px; padding: 6px 12px; cursor: pointer;
}
.hud-btn:hover { border-color: var(--amber); }

/* hotseat handover privacy screen */
.handover {
  position: fixed; inset: 0; z-index: 90;
  background: #120c07; /* fully opaque: nothing of the office may show through */
  display: flex; align-items: center; justify-content: center;
}
.handover-box {
  text-align: center; border: 2px solid; border-radius: 10px;
  padding: 42px 56px; background: var(--panel);
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}
.handover-hint { color: var(--paper-dark); font-size: 14px; letter-spacing: 1px; margin-bottom: 18px; }
.handover-name { font-size: 42px; font-weight: bold; letter-spacing: 3px; margin-bottom: 8px; }
.handover-cal { color: var(--amber); margin-bottom: 26px; }
.handover button {
  font-size: 16px; padding: 12px 26px; cursor: pointer;
  background: var(--panel); color: var(--paper);
  border: 2px solid; border-radius: 6px; font-family: inherit;
}
.handover button:hover { background: rgba(255,180,84,0.12); }

/* game over */
.gameover {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.gameover h1 { font-size: 46px; color: var(--amber); text-shadow: 0 0 24px rgba(255,180,84,0.5); }
.gameover table { font-size: 16px; }
/* Farewell verdict of Die Schmierfeder on AI wins - newspaper style, like
   the paper's own column items (amber rule, signed, italic text). NOTE:
   deliberately NOT named .farewell - that class is the full-screen quit
   overlay, and reusing it turned the verdict into a viewport-sized cover
   that hid the ranking and the button. */
.gameover .farewell-note {
  border-left: 3px solid var(--amber-dim); padding: 6px 14px;
  max-width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 2px; text-align: left;
}
.gameover .farewell-sign { color: var(--amber-dim); font-size: 12px; letter-spacing: 1px; }
.gameover .farewell-text { font-style: italic; color: var(--paper); font-size: 15px; }
.gameover .farewell-facts { margin-top: 6px; color: var(--paper-dark); font-size: 12px; line-height: 1.6; }

/* toast */
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--amber); color: #241a0d; font-weight: bold;
  padding: 9px 18px; border-radius: 5px; z-index: 200; display: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5); max-width: 80vw;
  pointer-events: none; /* never block clicks on buttons underneath */
}

/* ---------- main menu (boot screen) ---------- */
.menu {
  max-width: 560px; margin: 0 auto; padding: 40px 24px; height: 100%;
  display: flex; flex-direction: column; gap: 18px; justify-content: center;
  overflow-y: auto;
}
.menu .logo { text-align: center; }
.menu .logo .big {
  font-size: 46px; letter-spacing: 4px; color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 180, 84, 0.45);
}
.menu .logo .sub { color: var(--paper-dark); font-size: 14px; letter-spacing: 2px; }
.menu .hint { text-align: center; }
.menu-stack { display: flex; flex-direction: column; gap: 10px; }
.menu-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 12px 18px; font-size: 17px; letter-spacing: 1px;
}
.menu-btn small {
  font-size: 11px; font-weight: normal; letter-spacing: 0.5px;
  color: rgba(36, 26, 13, 0.75); text-transform: none;
}
.menu-btn.ghost small { color: var(--paper-dark); }
.menu .meta { color: var(--paper-dark); font-size: 11px; text-align: center; line-height: 1.5; }

/* narrow viewports: the HUD row wraps regardless of pointer type
   (calendar + price/cash/oil/days + player badges do not fit in one line) */
@media (max-width: 900px) {
  .hud { flex-wrap: wrap; row-gap: 4px; }
  .hud .players { width: 100%; margin-left: 0; justify-content: center; flex-wrap: wrap; gap: 4px; }
}

/* ---------- in-game navigation bar ---------- */
.navbar {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; margin-top: 6px;
  border-top: 2px solid var(--amber-dim);
  background: rgba(46, 38, 32, 0.85);
}
.navbar .nb-brand { color: var(--amber); font-weight: bold; letter-spacing: 1px; font-size: 12px; }
.navbar .nb-btn {
  font-size: 11px; padding: 4px 10px; background: var(--panel);
  color: var(--paper); border: 1px solid var(--amber-dim); border-radius: 4px;
  box-shadow: none;
}
.navbar .nb-btn:hover { border-color: var(--amber); }
.navbar .nb-btn.danger { color: var(--red); border-color: var(--red); }
.navbar .nb-btn.danger:hover { background: rgba(230, 57, 70, 0.12); }
.navbar .nb-meta { margin-left: auto; color: var(--paper-dark); font-size: 10px; }
@media (max-width: 900px) {
  .navbar .nb-meta { display: none; }
}

/* ---------- farewell (app closed) ---------- */
.farewell {
  position: fixed; inset: 0; z-index: 300; background: #120c07;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 24px;
}
.farewell .big { font-size: 40px; letter-spacing: 4px; color: var(--amber-dim); }
.farewell .sub { color: var(--paper-dark); letter-spacing: 2px; }
.farewell .meta { color: var(--paper-dark); font-size: 11px; }
body.app-closed > #toast { display: none !important; }

/* ---------- attract mode (animated scene behind the main menu) ---------- */
.menu.attract {
  /* the menu box gets a translucent panel so the scene shines through
     only around the content - text stays readable */
  background: rgba(18, 12, 7, 0.55);
  border: 1px solid rgba(255, 180, 84, 0.25);
  border-radius: 10px;
  backdrop-filter: blur(1px);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
  position: relative; z-index: 1;   /* above the canvas */
}
.attract-scene {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;             /* clicks pass through to the menu */
}

/* very narrow screens (phone portrait): the office columns cannot keep
   2x190px + stage side by side - stack the columns under the stage */
@media (max-width: 640px) {
  .office { flex-direction: column; overflow-y: auto; }
  .col { width: 100%; flex-direction: row; }
  .desk-item { min-height: 64px; flex: 1; }
  .stage { min-height: 320px; }
  .stage .scene { font-size: 64px; }
  .menu { padding: 20px 14px; }
  .menu .logo .big { font-size: 30px; }
  .setup { padding: 20px 14px; }
}

/* bank risk preview: red when a full draw walks into the bankruptcy cliff */
.hint.danger { color: var(--red); font-weight: bold; }

/* auction-win markers: map pin + claim badge, pulse until first drill */
.worldmap .auction-pin {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  background: #241a0d; border-radius: 8px; font-size: 11px;
  animation: auctionPulse 1.2s ease-in-out infinite;
}
.auction-pin-pulse { animation: auctionPulse 1.2s ease-in-out infinite; }
@keyframes auctionPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.15); filter: brightness(1.5); }
}
.badge.auction { background: #241a0d; color: #ffb454; }
@media (prefers-reduced-motion: reduce) {
  .worldmap .auction-pin, .auction-pin-pulse { animation: none; }
}
