/* ============================================================
   PRICE WARS — game styles (language-agnostic).
   Loaded by commons/games/price-wars/game.php. The engine lives
   in price-wars.js; the copy lives in commons/games/price-wars/lang/.
   ============================================================ */

/* ==========================================================
   1. DESIGN TOKENS — "price ledger" theme: paper background,
      blue ink, monospace digits, green/red/amber signals
   ========================================================== */
:root {
  --paper:      #f7f8fa;   /* page background */
  --card:       #ffffff;   /* card surfaces */
  --ink:        #16233b;   /* primary text */
  --ink-soft:   #5b6b85;   /* secondary text */
  --line:       #dde3ec;   /* borders */
  --blue:       #2456f0;   /* primary accent (actions, brand) */
  --blue-soft:  #e8eeff;
  --green:      #0e9f6e;   /* profit / competitor price drop */
  --green-soft: #e4f7ef;
  --red:        #d64545;   /* loss / competitor price rise */
  --red-soft:   #fdecec;
  --amber:      #b7791f;   /* alerts, events */
  --amber-soft: #fdf3e0;
  --fog:        #aab4c4;   /* blind phase */
  --radius: 10px;
  --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num:  ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

/* Scoped reset: only elements inside the game wrapper, so the site's
   shared nav/footer (if ever added) and Tailwind base are untouched. */
.pw-app * { box-sizing: border-box; margin: 0; padding: 0; }

/* Paper background / ink color / UI font live on a full-height wrapper
   (.pw-app) rather than on the body element, because the shared site
   template gives the body Tailwind classes (font-sans text-gray-900
   bg-white) that would otherwise override a plain body rule. */
.pw-app {
  min-height: 100vh;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}

/* ==========================================================
   2. GENERAL LAYOUT
   ========================================================== */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px 16px 92px; }

header.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between;
  background: var(--ink); color: #fff;
  border-radius: var(--radius);
  padding: 12px 18px; margin-bottom: 16px;
}
.brand { font-weight: 800; letter-spacing: 0.06em; font-size: 18px; }
.brand small {
  display: block; font-weight: 500; letter-spacing: 0.02em;
  font-size: 11px; color: #9db1d8;
}
.topstats { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.topstat { text-align: right; }
.topstat .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: #9db1d8; }
.topstat .val { font-family: var(--font-num); font-size: 18px; font-weight: 700; }

.phase-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  padding: 5px 12px; border-radius: 999px; text-transform: uppercase;
}
.phase-badge.blind { background: #3a4a68; color: #c6d2e8; }
.phase-badge.live  { background: var(--green); color: #fff; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: 1.1fr 1.3fr 1fr;
}
.grid > * { min-width: 0; } /* allows cards to shrink below their content width */
@media (max-width: 960px) { .grid { grid-template-columns: 1fr 1fr; } .col-feed { grid-column: 1 / -1; } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.card h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-soft); margin-bottom: 10px;
}

/* ==========================================================
   3. PLAYER PRODUCTS (price stepper)
   ========================================================== */
.product { border-top: 1px solid var(--line); padding: 12px 0; }
.product:first-of-type { border-top: none; padding-top: 4px; }
.product .name { font-weight: 700; }
.product .meta {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 12px; color: var(--ink-soft); margin-bottom: 8px;
}

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  font-family: var(--font-num); font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 6px 9px; cursor: pointer;
}
.stepper button:hover { background: var(--blue-soft); border-color: var(--blue); }
.stepper .price {
  font-family: var(--font-num); font-size: 20px; font-weight: 700;
  min-width: 108px; text-align: center;
}
.margin-hint { font-size: 12px; font-weight: 600; white-space: nowrap; }
.margin-hint.ok   { color: var(--green); }
.margin-hint.low  { color: var(--amber); }
.margin-hint.loss { color: var(--red); }

.result-line { font-size: 12px; color: var(--ink-soft); margin-top: 4px; font-family: var(--font-num); }

/* ==========================================================
   4. MARKET TABLE (competitors)
   ========================================================== */
table.market { width: 100%; border-collapse: collapse; font-size: 13px; }
.market th, .market td { padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.market th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.market td:first-child, .market th:first-child { text-align: left; }
.market .num { font-family: var(--font-num); font-weight: 600; }
.market .you { color: var(--blue); }

.fogged { color: var(--fog); letter-spacing: 0.15em; font-family: var(--font-num); }
.delta-up   { color: var(--red); font-size: 11px; }
.delta-down { color: var(--green); font-size: 11px; }
.flash-tag {
  background: var(--amber-soft); color: var(--amber);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}

.spy-row { margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.btn {
  display: inline-block; border: none; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
  border-radius: 8px; padding: 9px 16px;
}
.btn-secondary { background: var(--blue-soft); color: var(--blue); }
.btn-secondary:hover { background: #d8e2ff; }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; font-size: 15px; padding: 12px 22px; }
.btn-primary:hover { background: #1a45d0; }

/* ==========================================================
   5. ALERTS FEED + PROFIT CHART
   ========================================================== */
.feed { list-style: none; max-height: 300px; overflow-y: auto; font-size: 13px; }
.feed li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.feed .day-tag { font-family: var(--font-num); font-size: 11px; color: var(--ink-soft); margin-right: 6px; }
.feed .alert-flash { color: var(--amber); font-weight: 600; }
.feed .alert-down  { color: var(--green); }
.feed .alert-up    { color: var(--red); }
.feed .alert-off   { color: var(--fog); font-style: italic; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 8px; }
.chart .bar { flex: 1; min-width: 4px; border-radius: 2px 2px 0 0; }
.chart .bar.pos { background: var(--green); }
.chart .bar.neg { background: var(--red); }

/* ==========================================================
   6. ACTION BAR + EVENTS
   ========================================================== */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(22,35,59,0.10);
  /* content aligns to the same centered column as the rest of the page (wrap = 1180px) */
  padding: 12px max(16px, calc((100% - 1180px) / 2 + 16px)) calc(12px + env(safe-area-inset-bottom));
}
.event-banner { font-size: 13px; font-weight: 600; color: var(--amber); }

/* ==========================================================
   6b. MOBILE — narrow screens + touch devices
   ========================================================== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .wrap { padding: 10px 10px 96px; } /* room for the fixed bottom bar */

  /* compact two-row header */
  header.topbar { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 15px; }
  .topstats { width: 100%; justify-content: space-between; gap: 10px; }
  .topstat .val { font-size: 15px; }
  .topstat { text-align: left; }

  /* larger touch targets that can still shrink */
  .stepper { justify-content: space-between; width: 100%; gap: 4px; }
  .stepper button { flex: 1 1 0; min-width: 0; padding: 12px 8px; font-size: 15px; }
  .stepper .price { flex: 1.6 1 0; font-size: 18px; min-width: 0; }

  .market th, .market td { padding: 8px 5px; font-size: 12px; white-space: nowrap; }

  /* action bar: tighter padding on mobile (fixed position comes from the base rule) */
  .actionbar {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }
  .event-banner { font-size: 12px; flex: 1; min-width: 0; }
  .btn-primary { padding: 12px 18px; white-space: nowrap; }

  .feed { max-height: 200px; }
  .modal { padding: 20px; }
  .modal h1 { font-size: 20px; }
  .big-compare .box .val { font-size: 19px; }
}

/* touch: no persistent hover effects, press feedback instead */
@media (hover: none) {
  .stepper button:active { background: var(--blue-soft); border-color: var(--blue); }
  .btn-primary:active { background: #1a45d0; }
}

/* ==========================================================
   7. MODALS (intro, FastCompete activation, end screen)
   ========================================================== */
.overlay {
  position: fixed; inset: 0; background: rgba(22, 35, 59, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal {
  background: var(--card); border-radius: 14px; max-width: 560px; width: 100%;
  padding: 26px; box-shadow: 0 18px 50px rgba(22,35,59,0.3);
}
.modal h1 { font-size: 24px; margin-bottom: 4px; }
.modal h1 span { color: var(--blue); }
.modal h1.wordmark span { color: inherit; } /* game title: single font/color, no accent */
.modal p { margin: 10px 0; font-size: 14px; color: var(--ink-soft); }
.modal .big-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0;
}
.big-compare .box {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center;
}
.big-compare .box .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.big-compare .box .val { font-family: var(--font-num); font-size: 24px; font-weight: 800; }
.big-compare .box.win { border-color: var(--green); background: var(--green-soft); }
.big-compare .box.win .val { color: var(--green); }

/* end-screen buttons: full width, text can wrap on mobile */
.end-cta {
  display: block; width: 100%; box-sizing: border-box;
  text-align: center; text-decoration: none;
  white-space: normal; word-break: break-word; line-height: 1.35;
  margin-top: 10px;
}
.hidden { display: none; }
