/* ═══════════════════════ STOCKGUESSR — terminal noir ═══════════════════════ */

/* Self-hosted fonts (latin subset, covers French) — no Google requests, no GDPR exposure */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/IBMPlexMono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: italic; font-weight: 400; font-display: swap;
  src: url('fonts/IBMPlexMono-400i.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/IBMPlexMono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/IBMPlexMono-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/InstrumentSerif-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic; font-weight: 400; font-display: swap;
  src: url('fonts/InstrumentSerif-400i.woff2') format('woff2');
}

:root {
  --bg: #050605;
  --panel: #0a0c0a;
  --line: #1a1f1a;
  --txt: #d8e0d8;
  --dim: #5a675a;
  --green: #2dff8a;
  --red: #ff3b4f;
  --amber: #ffc24b;
  --mono: 'IBM Plex Mono', monospace;
  --serif: 'Instrument Serif', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--mono);
  overflow-x: hidden;
}

/* atmosphere */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,.18) 2px 4px);
  mix-blend-mode: multiply;
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 49;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(0,0,0,.55));
}

.screen { display: none; min-height: 100vh; }
/* fill-mode backwards, NOT both: a lingering fill transform would turn .screen
   into the containing block for position:fixed (the docked guess input) */
.screen.active { display: flex; flex-direction: column; animation: screenIn .5s ease backwards; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ════════ MENU ════════ */
#screen-menu { align-items: center; justify-content: center; padding: 48px 24px; position: relative; }
.menu-inner { width: min(860px, 100%); text-align: center; }

.ticker-tape {
  font-size: 11px; letter-spacing: .12em; color: var(--dim);
  white-space: nowrap; overflow: hidden; margin-bottom: 48px;
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}
.ticker-tape span { display: inline-block; padding-right: 48px; animation: tape 40s linear infinite; }
@keyframes tape { to { transform: translateX(-50%); } }
.tape-up { color: var(--green); }
.tape-down { color: var(--red); }

.logo {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(36px, 7vw, 72px);
  letter-spacing: .14em; line-height: 1;
  animation: flicker 4s infinite;
}
.logo-accent { color: var(--green); text-shadow: 0 0 24px rgba(45,255,138,.45); }
@keyframes flicker {
  0%, 100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .75; } 94% { opacity: 1; }
  96% { opacity: .85; } 97% { opacity: 1; }
}
.tagline {
  font-family: var(--serif); font-size: clamp(18px, 2.6vw, 26px);
  color: var(--dim); margin: 14px 0 56px;
}
.tagline em { color: var(--txt); font-style: italic; }

.diff-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; text-align: left;
}
.diff-card {
  background: var(--panel); border: 1px solid var(--line);
  padding: 22px 18px 18px; cursor: pointer; color: var(--txt);
  font-family: var(--mono); display: flex; flex-direction: column; gap: 10px;
  position: relative; transition: border-color .2s, transform .2s, box-shadow .2s;
  animation: cardIn .55s ease backwards;
}
.diff-card:nth-child(1) { animation-delay: .08s; }
.diff-card:nth-child(2) { animation-delay: .16s; }
.diff-card:nth-child(3) { animation-delay: .24s; }
.diff-card:nth-child(4) { animation-delay: .32s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } }
.diff-card:hover {
  border-color: var(--green); transform: translateY(-4px);
  box-shadow: 0 12px 36px -12px rgba(45,255,138,.25);
}
.diff-card:hover .diff-name { color: var(--green); }
.diff-num { font-size: 11px; color: var(--dim); letter-spacing: .2em; }
.diff-name {
  font-family: var(--serif); font-style: italic; font-size: 30px;
  line-height: 1; transition: color .2s;
}
.diff-desc { font-size: 11.5px; line-height: 1.6; color: var(--dim); flex: 1; }
.diff-meter { display: block; height: 3px; background: var(--line); }
.diff-meter i {
  display: block; height: 100%; width: var(--w);
  background: linear-gradient(90deg, var(--green), var(--red));
}

/* global settings (market + lang) — top right, above the daily; desktop only */
.global-row {
  display: flex; justify-content: flex-end; gap: 16px 30px; flex-wrap: wrap;
  margin-bottom: 14px;
  animation: cardIn .55s ease .02s backwards;
}

/* separator between the daily and the training zone */
.zone-sep {
  display: flex; align-items: center; gap: 14px;
  margin: 24px 0 16px; color: var(--dim);
  font-size: 10px; letter-spacing: .3em;
}
.zone-sep::before, .zone-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* daily challenge — full-width amber card above the grid */
.daily-card {
  width: 100%; text-align: left; margin-bottom: 14px;
  border-color: rgba(255,194,75,.35); animation-delay: .04s;
}
.daily-card .diff-num { color: var(--amber); }
.daily-streak {
  position: absolute; top: 14px; right: 16px;
  font-size: 13px; font-weight: 600; letter-spacing: .08em;
  color: var(--amber); border: 1px solid rgba(255,194,75,.45);
  padding: 5px 10px;
  text-shadow: 0 0 10px rgba(255,194,75,.5);
}
.daily-streak[hidden] { display: none; }
.daily-card:hover {
  border-color: var(--amber);
  box-shadow: 0 12px 36px -12px rgba(255,194,75,.25);
}
.daily-card:hover .diff-name { color: var(--amber); }
.daily-meter i { background: linear-gradient(90deg, var(--amber), var(--green)); }
.daily-card.played { cursor: default; opacity: .7; }
.daily-card.played:hover {
  transform: none; box-shadow: none;
  border-color: rgba(255,194,75,.35);
}
.daily-card.played:hover .diff-name { color: var(--txt); }
.daily-card.played .diff-desc { color: var(--amber); }
.rounds-row {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; margin-bottom: 16px;
  animation: cardIn .55s ease .06s backwards;
}
.rounds-row .field-label { white-space: nowrap; }
.rr-group { display: flex; align-items: center; gap: 16px; }

@media (max-width: 700px) {
  /* global settings: one line, labels stacked above their pills */
  #screen-menu .global-row {
    justify-content: center; gap: 12px 22px; flex-wrap: nowrap;
    margin-bottom: 18px;
  }
  #screen-menu .global-row .rr-group {
    flex-direction: column; align-items: flex-start; gap: 8px;
  }
  #screen-menu .global-row .tf-pills { flex-wrap: nowrap; }
  #screen-menu .global-row .tf-pill {
    padding: 9px 10px; font-size: 11px; white-space: nowrap;
  }
  .rounds-row .tf-pills { flex-wrap: nowrap; }
  .rounds-row .tf-pill {
    padding: 9px 12px; font-size: 11px; white-space: nowrap;
  }
  /* hints: one swipeable line, right-edge fade hints at more */
  #hint-pills {
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 90%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent);
  }
  #hint-pills::-webkit-scrollbar { display: none; }
  #hint-pills .btn-hint { flex: 0 0 auto; white-space: nowrap; }
  #btn-submit, .btn-next { align-self: center; }
}
/* very narrow phones: squeeze so the settings line still fits */
@media (max-width: 359px) {
  #screen-menu .global-row { gap: 12px 14px; }
  #screen-menu .global-row .tf-pills { gap: 5px; }
  #screen-menu .global-row .tf-pill { padding: 9px 7px; font-size: 10px; }
}
.menu-foot { margin-top: 48px; font-size: 11px; letter-spacing: .18em; color: var(--dim); }

/* ════════ GAME ════════ */
#screen-game { padding: 0 clamp(16px, 4vw, 48px) 40px; max-width: 980px; margin: 0 auto; width: 100%; }

.game-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 20px 0 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; letter-spacing: .14em;
}
.gh-left, .gh-right { display: flex; gap: 22px; align-items: baseline; }
.gh-brand { color: var(--dim); }
.gh-round { color: var(--txt); }
.gh-market { color: var(--dim); }
.gh-level { color: var(--amber); }
.gh-score { color: var(--green); text-shadow: 0 0 12px rgba(45,255,138,.4); }

.chart-stage { padding: 28px 0 18px; }
.chart-frame { position: relative; }
#chart { display: block; width: 100%; height: clamp(260px, 42vh, 420px); }
.intel-card {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  background: rgba(10,12,10,.88); border: 1px solid var(--amber);
  padding: 12px 16px; max-width: 200px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 0 24px -8px rgba(255,194,75,.35);
  animation: cardIn .5s ease .3s backwards;
}
.intel-card[hidden] { display: none; }
/* fade so the chart underneath stays readable — hover on desktop, tap on mobile */
.intel-card { transition: opacity .25s; cursor: pointer; }
@media (hover: hover) { .intel-card:hover { opacity: .12; } }
.intel-card.peek { opacity: .12; }
.intel-label { font-size: 9px; letter-spacing: .26em; color: var(--amber); }
.intel-row { font-size: 13px; color: var(--txt); }
.intel-row b { color: var(--amber); font-weight: 600; }
.intel-sector { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }

.chart-corners i {
  position: absolute; width: 14px; height: 14px; border: 1px solid var(--dim);
}
.chart-corners i:nth-child(1) { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.chart-corners i:nth-child(2) { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.chart-corners i:nth-child(3) { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.chart-corners i:nth-child(4) { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* guess panel */
.guess-panel { display: flex; flex-direction: column; gap: 18px; }
.guess-row { position: relative; }
.field { display: flex; flex-direction: column; gap: 8px; position: relative; }
.field-label { font-size: 10px; letter-spacing: .22em; color: var(--dim); }

#guess-input {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  font-family: var(--mono); font-size: 16px; padding: 13px 16px;
  outline: none; width: 100%; caret-color: var(--green);
  transition: border-color .2s;
}
/* type="search" keeps browser autofill (passwords/cards/addresses) away; undo its native skin */
#guess-input { -webkit-appearance: none; appearance: none; border-radius: 0; }
#guess-input::-webkit-search-decoration,
#guess-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
#guess-input:focus { border-color: var(--green); box-shadow: 0 0 0 1px rgba(45,255,138,.2); }
#guess-input::placeholder { color: #3a443a; font-style: italic; }
#guess-input.locked { border-color: var(--green); color: var(--green); }

/* mobile focus: the field floats up to mid-chart over a blurred backdrop (see app.js) */
.field-company.docked {
  position: fixed; left: 12px; right: 12px; z-index: 200;
  background: var(--bg); padding: 10px 14px 12px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px -10px rgba(0,0,0,.9);
}
.field-company.docked .ac-list {
  /* line up with the input despite the docked panel's padding */
  left: 14px; right: 14px; top: calc(100% - 12px);
  border-top: 1px solid var(--green);
  box-shadow: 0 18px 60px -10px rgba(0,0,0,.9);
}
.dock-backdrop {
  position: fixed; inset: 0; z-index: 150; pointer-events: none;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  opacity: 0; transition: opacity .25s;
}
.dock-backdrop.show { opacity: 1; }

.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  list-style: none; background: #090b09; border: 1px solid var(--green);
  border-top: 0; max-height: 264px; overflow-y: auto;
}
.ac-list li {
  padding: 10px 16px; font-size: 14px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px;
}
.ac-list li .ac-ticker { color: var(--dim); font-size: 12px; }
.ac-list li:hover, .ac-list li.sel { background: rgba(45,255,138,.12); color: var(--green); }
.ac-list li:hover .ac-ticker, .ac-list li.sel .ac-ticker { color: var(--green); }

.tf-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.tf-pill {
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  font-family: var(--mono); font-size: 13px; letter-spacing: .08em;
  padding: 10px 18px; cursor: pointer; transition: all .15s;
}
.tf-pill:hover { border-color: var(--dim); color: var(--txt); }
.tf-pill.sel {
  border-color: var(--green); color: var(--green);
  background: rgba(45,255,138,.08); box-shadow: 0 0 14px -4px rgba(45,255,138,.5);
}

#hint-row[hidden] { display: none; }
.hint-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-hint {
  background: none; border: 1px dashed var(--line); color: var(--amber);
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  padding: 9px 14px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-hint:hover { border-color: var(--amber); }

.btn-submit {
  margin-top: 4px; align-self: flex-start;
  background: var(--green); border: 0; color: #04140a;
  font-family: var(--mono); font-weight: 600; font-size: 14px;
  letter-spacing: .18em; padding: 15px 34px; cursor: pointer;
  transition: all .15s;
  box-shadow: 0 0 24px -6px rgba(45,255,138,.5);
}
.btn-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 32px -6px rgba(45,255,138,.7); }
.btn-submit:disabled { background: var(--line); color: var(--dim); cursor: not-allowed; box-shadow: none; }

/* reveal */
.reveal-panel { display: flex; flex-direction: column; gap: 20px; animation: screenIn .4s ease both; }
.reveal-panel[hidden] { display: none; }
.reveal-verdict {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(30px, 5vw, 46px); line-height: 1;
}
.reveal-verdict.good { color: var(--green); text-shadow: 0 0 28px rgba(45,255,138,.4); }
.reveal-verdict.mid { color: var(--amber); }
.reveal-verdict.bad { color: var(--red); text-shadow: 0 0 28px rgba(255,59,79,.35); }

.reveal-solution {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.rs-block { background: var(--panel); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.rs-label { font-size: 10px; letter-spacing: .22em; color: var(--dim); }
.rs-value { font-size: 16px; }
.rs-points { color: var(--green); font-weight: 600; }
.rs-mark { position: absolute; top: 12px; right: 14px; font-size: 14px; font-weight: 600; }
.rs-mark.ok { color: var(--green); }
.rs-mark.ko { color: var(--red); }

/* ════════ RESULTS ════════ */
#screen-results { align-items: center; justify-content: center; padding: 48px 24px; }
.results-inner { width: min(640px, 100%); text-align: center; }
.results-over { font-size: 11px; letter-spacing: .3em; color: var(--dim); margin-bottom: 18px; }
.results-grade {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(34px, 6vw, 56px); line-height: 1.05; margin-bottom: 10px;
  color: var(--txt);
}
.results-score {
  font-size: clamp(48px, 9vw, 92px); font-weight: 600; color: var(--green);
  text-shadow: 0 0 36px rgba(45,255,138,.45); margin-bottom: 36px; line-height: 1;
}
.results-score .rs-max { font-size: .35em; color: var(--dim); text-shadow: none; font-weight: 400; }

.results-list { list-style: none; text-align: left; border: 1px solid var(--line); margin-top: 32px; }
.results-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; font-size: 13px; border-bottom: 1px solid var(--line);
  animation: cardIn .4s ease backwards;
}
.results-list li:last-child { border-bottom: 0; }
.rl-num { color: var(--dim); font-size: 11px; width: 22px; }
.rl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-tf { color: var(--dim); width: 42px; }
.rl-marks { width: 48px; letter-spacing: .2em; }
.rl-pts { width: 70px; text-align: right; color: var(--green); }
.rl-pts.zero { color: var(--dim); }
.ok { color: var(--green); }
.ko { color: var(--red); }

/* sponsor slot */
.sponsor-card {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  text-align: left; text-decoration: none;
  border: 1px dashed #3a4435; background: rgba(255,194,75,.03);
  padding: 14px 18px;
  transition: border-color .2s, background .2s;
}
.share-box .sponsor-card { align-self: stretch; }
.sponsor-card[hidden] { display: none; }
.sponsor-card:hover { border-color: var(--amber); background: rgba(255,194,75,.07); }
.sponsor-tag { font-size: 9px; letter-spacing: .24em; color: #8a7a4d; }
.sponsor-text { font-size: 13px; color: var(--txt); flex: 1; min-width: 200px; }
.sponsor-cta { font-size: 12px; letter-spacing: .1em; color: var(--amber); white-space: nowrap; }
.sponsor-card:hover .sponsor-cta { text-shadow: 0 0 12px rgba(255,194,75,.5); }
.sponsor-disclaimer { flex-basis: 100%; font-size: 10px; color: var(--dim); }

/* share */
.share-box { display: flex; flex-direction: column; align-items: center; gap: 18px; }
#share-img {
  width: min(280px, 70vw); border: 1px solid var(--line);
  box-shadow: 0 18px 48px -18px rgba(45,255,138,.25);
  transform: rotate(-1.2deg);
  transition: transform .25s;
}
#share-img:hover { transform: rotate(0deg) scale(1.02); }
.share-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-share { background: var(--bg); color: var(--green); border: 1px solid var(--green); }
a.btn-submit { display: inline-block; text-decoration: none; line-height: normal; }
.share-actions .btn-submit { padding: 13px 22px; font-size: 13px; }
.btn-share:hover { box-shadow: 0 6px 32px -6px rgba(45,255,138,.5); }
.share-feedback { font-size: 11px; letter-spacing: .14em; color: var(--amber); min-height: 14px; }

@media (max-width: 560px) {
  .gh-left, .gh-right { gap: 12px; }
  .gh-brand { display: none; }
  .game-header { flex-wrap: wrap; row-gap: 4px; }
}
