/* Hack the Bot – alpine wayfinding look: yellow signposts, granite type, red-white-red trail
   markers for cracked targets. Yellow is reserved for signs, red for cracks/leaks/errors. */

:root {
  --bg: #f3f5f4;          /* snowfield */
  --panel: #ffffff;
  --text: #22282a;        /* granite */
  --muted: #6e7773;       /* stone */
  --border: #d5dbd8;
  --sign: #ffcc00;        /* wayfinding yellow */
  --sign-text: #22282a;
  --accent: #22282a;      /* primary buttons: granite */
  --accent-text: #ffffff;
  --ok: #3e6b5a;          /* lichen */
  --ok-bg: #e2ece7;
  --warn: #8a6a00;
  --warn-bg: #fff4c7;
  --err: #d21f2b;         /* trail red */
  --err-bg: #fbe5e6;
  --user-bg: #e6ebe9;
  --bot-bg: #ffffff;
  --radius: 4px;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b2022;
    --panel: #232a2c;
    --text: #e9eeec;
    --muted: #9aa5a0;
    --border: #3a4447;
    --sign-text: #1b2022;
    --accent: #e9eeec;
    --accent-text: #1b2022;
    --ok: #7fb8a0;
    --ok-bg: #213530;
    --warn: #ffd84d;
    --warn-bg: #3a3214;
    --err: #ff5a64;
    --err-bg: #3f1f22;
    --user-bg: #2e3739;
    --bot-bg: #1b2022;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--body);
}

h1, h2, h3, button, .badge, .stat, a.button, th {
  font-family: var(--display);
}

:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; }

/* header: granite band, phase as a yellow sign */
header.top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: #22282a;
  color: #f3f5f4;
}
header.top h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: .01em; }
header.top .spacer { flex: 1; }
header.top #teamname { font-family: var(--display); font-size: 20px; font-weight: 600; }
header.top button.secondary { color: #f3f5f4; border-color: #6e7773; }
header.top .badge { border: 0; }

main { padding: 24px; max-width: 1500px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 22px; font-weight: 700; margin: 0 0 10px; line-height: 1.15; }
.panel h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.panel p { max-width: 75ch; }

.grid2 { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.4fr); gap: 18px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
/* one column per model; --cols is set by the page */
.cols.models { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
@media (max-width: 1100px) { .cols.models.wide { --cols: 2 !important; } }
@media (max-width: 640px) { .cols.models { --cols: 1 !important; } }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.hidden { display: none !important; }

textarea, input[type=text], input[type=password] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
}
textarea:focus, input:focus { border-color: var(--text); outline: none; box-shadow: 0 0 0 3px var(--sign); }
textarea { resize: vertical; }
textarea.prompt { min-height: 360px; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--bg); }
input.inline { width: auto; flex: 1; min-width: 120px; }

button, a.button {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius);
  padding: 5px 16px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
button:hover:not(:disabled), a.button:hover { filter: brightness(1.15); }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* the scoreboard link in the header is a yellow sign */
a.button { background: var(--sign); border-color: var(--sign); color: var(--sign-text); }

.badge {
  display: inline-block;
  padding: 1px 10px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.phase-DEFENSE, .phase-LOCKED, .phase-ATTACK, .phase-FINISHED { background: var(--sign); color: var(--sign-text); border-color: var(--sign); }
.phase-ATTACK { background: var(--err); color: #fff; border-color: var(--err); }
.phase-FINISHED { background: transparent; color: inherit; border-color: currentColor; }

.msg { min-height: 1.2em; font-size: 13.5px; }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--err); }
.msg.warn { color: var(--warn); }

.counter.over { color: var(--err); font-weight: 600; }

/* the team's own code: a yellow sign */
.secret {
  background: var(--sign);
  color: var(--sign-text);
  border: 0;
  font-size: 15px;
}
.secret strong { font-family: var(--display); font-size: 20px; letter-spacing: .04em; }
.secret code { background: rgba(255, 255, 255, .55); padding: 1px 5px; border-radius: 3px; }

/* chats */
.chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 440px;
  min-height: 80px;
  overflow-y: auto;
  padding: 4px 2px;
}
.bubble {
  padding: 8px 11px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  border: 1px solid var(--border);
}
.bubble.user { background: var(--user-bg); border-color: transparent; align-self: flex-end; max-width: 92%; }
.bubble.assistant { background: var(--bot-bg); align-self: flex-start; max-width: 96%; }
.bubble.leak { border: 2px solid var(--err); }
.bubble code { font-family: var(--mono); font-size: 0.9em; background: var(--bg); border-radius: 3px; padding: 0 3px; }
.bubble.error { background: var(--err-bg); color: var(--err); }
.bubble .meta { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }

.column {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
}
/* cracked: red-white-red trail marker along the top edge */
.column.cracked {
  border-color: var(--err);
  background-image: linear-gradient(to bottom, var(--err) 0 5px, #fff 5px 10px, var(--err) 10px 15px);
  background-size: 100% 15px;
  background-repeat: no-repeat;
  padding-top: 24px;
}
.column header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.column header strong { font-family: var(--display); font-size: 17px; font-weight: 600; }
.column.cracked .badge { background: var(--err); color: #fff; border-color: var(--err); }

.leakwarn { background: var(--err); color: #fff; padding: 6px 10px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600; }

/* tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 16px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pass { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.fail { color: var(--err); font-weight: 600; }

/* attack */
.target-group { margin-bottom: 18px; }
.target-group > h3 { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
.stat { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* login: a single signpost */
.login { max-width: 440px; margin: 12vh auto; border-top: 10px solid var(--sign); }
.login input { font-family: var(--display); font-size: 26px; letter-spacing: .12em; text-transform: uppercase; text-align: center; }

pre.block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  max-height: 360px;
  overflow-y: auto;
}

details summary { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* header extras: rules link, countdown sign */
header.top .headerlink { color: #f3f5f4; font-size: 14px; }
.timer {
  font-family: var(--display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--sign); color: var(--sign-text); border-radius: var(--radius); padding: 0 10px;
}
.timer.urgent { background: var(--err); color: #fff; }

/* results: podium with trophies (2 – 1 – 3), then the full ranking */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 10px 0 24px; flex-wrap: wrap; }
.step { width: 190px; text-align: center; }
.step .trophy { font-size: 40px; line-height: 1; }
.step1 .trophy { font-size: 56px; }
.step .who { font-family: var(--display); font-size: 22px; margin: 6px 0 2px; overflow-wrap: anywhere; }
.step .points { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.step .block {
  background: var(--sign); color: var(--sign-text); font-family: var(--display); font-weight: 800; font-size: 44px;
  border-radius: var(--radius) var(--radius) 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px;
}
.step1 .block { height: 150px; }
.step2 .block { height: 110px; }
.step3 .block { height: 80px; }
.fullranking { list-style: none; padding: 0; margin: 0 0 12px; max-width: 520px; }
.fullranking li { display: grid; grid-template-columns: 6rem 1fr auto; gap: 10px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.fullranking li.mine { background: var(--warn-bg); font-weight: 600; }
.fullranking .sc { font-family: var(--display); font-size: 18px; font-variant-numeric: tabular-nums; }

/* review timeline */
.journal-attempt { border-left: 3px solid var(--border); padding: 6px 0 6px 12px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.journal-attempt.hit { border-left-color: var(--err); }
.journal-attempt .bubble.user { align-self: flex-start; }
.journal-guess { font-size: 14px; margin: 6px 0 6px 15px; }
.crackbadge { background: var(--err); color: #fff; border-color: var(--err); }
.divider { margin: 18px 0 6px; padding: 6px 10px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
