/* PATCH #23867 — the game is fake software. This stylesheet is its operating system.
   Trac's visual language, legally distinct: tan chrome, that institutional blue,
   boxed comments, monospace props. It should be screenshot-indistinguishable. */

:root {
  --trac-blue: #5b6fa8;
  --trac-blue-dark: #3d4d7a;
  --trac-link: #2b56a5;
  --tan: #f7f6f0;
  --tan-edge: #e6e2d3;
  --ink: #2b2b28;
  --muted: #6c6a60;
  --line: #d6d2c4;
  --you: #1c6a3a;
  --green: #3a8a4f;
  --red: #a23b3b;
  --amber: #c98a2b;
  --bot: #8a5a8a;
  --paper-shadow: 0 1px 0 #fff, 0 2px 6px rgba(40,38,30,.08);
  --mono: "SFMono-Regular", "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Verdana, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--ui);
  font-size: 14px;
  color: var(--ink);
  background: #cfcabb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M0 0h6v6H0z' fill='%23cfcabb'/%3E%3Cpath d='M0 0h1v1H0z' fill='%23c7c2b3'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
}

#screen { max-width: 1100px; margin: 0 auto; min-height: 100vh; background: var(--tan); box-shadow: 0 0 40px rgba(0,0,0,.18); display: flex; flex-direction: column; }

/* ---- fake browser tab bar ---- */
#tabbar { display: flex; align-items: stretch; background: #d9d4c6; border-bottom: 1px solid var(--tan-edge); font-size: 12px; }
.tab { padding: 7px 16px; border-right: 1px solid var(--tan-edge); color: var(--muted); }
.tab.active { background: var(--tan); color: var(--ink); font-weight: 600; }
.tab.ghost { opacity: .55; }
#clock { margin-left: auto; padding: 7px 16px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- trac head ---- */
#trac-head { background: linear-gradient(180deg, var(--trac-blue) 0%, var(--trac-blue-dark) 100%); color: #eef0f7; padding: 10px 18px 0; }
#trac-head .logo { font-size: 20px; font-weight: 700; letter-spacing: -.5px; }
#trac-head .logo span { opacity: .7; font-weight: 400; }
#trac-head nav { display: flex; gap: 2px; margin-top: 8px; }
#trac-head nav a { font-size: 12px; padding: 5px 12px; color: #d7ddee; background: rgba(255,255,255,.06); border-radius: 3px 3px 0 0; cursor: default; }
#trac-head nav a.active { background: var(--tan); color: var(--trac-blue-dark); font-weight: 600; }

/* ---- ticket head ---- */
#ticket-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); background: #fbfaf5; }
.tnum { font-size: 12px; color: var(--muted); }
.ttype { color: var(--red); }
#ticket-title { font-size: 19px; margin: 4px 0 10px; font-weight: 600; line-height: 1.25; }
#ticket-props { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 2px 18px; font-family: var(--mono); font-size: 11.5px; }
#ticket-props .prop { display: flex; gap: 6px; padding: 1px 0; }
#ticket-props .prop b { color: var(--muted); font-weight: 600; min-width: 78px; }
#ticket-props .prop .val { color: var(--ink); }
#ticket-props .prop .val.warn { color: var(--red); font-weight: 700; }

/* ---- main layout ---- */
main { display: grid; grid-template-columns: 1fr 300px; flex: 1; align-items: start; }
#thread { padding: 14px 18px 60px; min-height: 50vh; }

/* ---- comments ---- */
.comment { background: #fff; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 12px; box-shadow: var(--paper-shadow); animation: drop .25s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.comment.description { background: #fffef9; border-color: #e3dcc4; }
.comment-head { display: flex; align-items: baseline; gap: 8px; padding: 7px 12px; border-bottom: 1px solid #f0ede2; font-size: 12px; background: #faf8f1; border-radius: 4px 4px 0 0; }
.comment-head .num { color: var(--muted); margin-right: 2px; }
.comment-body { padding: 10px 12px; line-height: 1.5; }
.author { font-weight: 700; }
.author.you { color: var(--you); }
.author.greg, .author.barry, .author.stranger { color: var(--trac-blue-dark); }
.author.jen { color: #8a2f6a; }
.author.bot { color: var(--bot); }
.author.system, .author.trac, .author.milestone { color: var(--muted); font-style: italic; font-weight: 600; }
.when { color: #a6a294; font-size: 11px; }

.comment.kind-system .comment-body, .comment.kind-merge .comment-body { font-family: var(--mono); font-size: 12.5px; }
.comment.kind-system { background: #f6f4ec; }
.comment.kind-merge { background: #eef6ee; border-color: #bcd9bf; }
.comment.kind-merge .comment-body { color: var(--green); font-weight: 700; }
.comment.kind-note { background: #f3f0fb; border-color: #ddd5ef; }
.comment.kind-note .comment-body { font-style: italic; color: #57516a; }

/* ---- HUD sidebar ---- */
#hud { position: sticky; top: 0; padding: 14px 16px; border-left: 1px solid var(--line); background: #f1efe6; min-height: 100vh; }
.hud-block { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 9px 11px; margin-bottom: 12px; }
.hud-era { font-weight: 700; color: var(--trac-blue-dark); }
.hud-cycle { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.hud-milestone { font-size: 12px; margin-top: 4px; }

.meter { margin-bottom: 10px; }
.meter label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.bar { height: 12px; background: #ddd9cc; border-radius: 7px; overflow: hidden; margin-top: 3px; box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.bar span { display: block; height: 100%; width: 60%; background: linear-gradient(180deg,#6fbf7f,#3a8a4f); transition: width .4s ease, background .4s; }
.bar.cred span { background: linear-gradient(180deg,#7d92c8,#3d4d7a); }
.bar.fresh span { background: linear-gradient(180deg,#e0b65c,#c98a2b); }
.bar.low span { background: linear-gradient(180deg,#d56a6a,#a23b3b) !important; }

.pips { display: flex; gap: 5px; margin-top: 4px; }
.pip { width: 20px; height: 20px; border-radius: 50%; background: #ddd9cc; border: 1px solid #c8c3b2; box-shadow: inset 0 1px 2px rgba(0,0,0,.1); }
.pip.full { background: radial-gradient(circle at 35% 30%, #ffe9a8, #e0a91f); border-color: #c08e12; }

.hud-traits { margin: 6px 0 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.trait { font-size: 10.5px; background: #efe8d4; border: 1px solid #ddd3b8; color: #7a6a38; padding: 2px 7px; border-radius: 10px; }

/* ---- actions ---- */
#actions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.action { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 8px 10px; cursor: pointer; font: inherit; transition: transform .08s, box-shadow .12s, border-color .12s; }
.action:hover:not(:disabled) { border-color: var(--trac-blue); box-shadow: 0 2px 6px rgba(60,77,122,.18); transform: translateY(-1px); }
.action:disabled { opacity: .45; cursor: not-allowed; }
.action .a-top { display: flex; justify-content: space-between; align-items: baseline; }
.action .a-label { font-weight: 600; }
.action .a-cost { font-size: 11px; color: var(--amber); font-weight: 700; font-variant-numeric: tabular-nums; }
.action .a-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.action.grass .a-label { color: var(--green); }

.end-cycle { width: 100%; margin-top: 12px; padding: 10px; border: none; border-radius: 4px; background: var(--trac-blue-dark); color: #fff; font: inherit; font-weight: 700; cursor: pointer; transition: background .15s; }
.end-cycle:hover { background: #2c3a60; }
.hint { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.4; min-height: 14px; }

/* ---- overlay / modals ---- */
#overlay { position: fixed; inset: 0; background: rgba(30,28,22,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
#overlay.hidden { display: none; }
.modal { background: var(--tan); border-radius: 8px; max-width: 560px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.4); overflow: hidden; animation: pop .25s ease; max-height: 90vh; display: flex; flex-direction: column; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-head { padding: 14px 18px; background: linear-gradient(180deg, var(--trac-blue), var(--trac-blue-dark)); color: #fff; }
.modal-head .m-author { font-size: 12px; opacity: .85; }
.modal-head .m-title { font-size: 17px; font-weight: 700; margin-top: 2px; }
.modal-quote { padding: 14px 18px; background: #fffef9; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.modal-quote.note { font-family: var(--ui); font-style: italic; color: #57516a; background: #f3f0fb; }
.modal-body { padding: 12px 18px; color: var(--muted); line-height: 1.5; font-size: 13px; }
.modal-choices { padding: 6px 18px 18px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.choice { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 11px 13px; cursor: pointer; font: inherit; line-height: 1.4; transition: border-color .12s, box-shadow .12s, transform .08s; }
.choice:hover { border-color: var(--trac-blue); box-shadow: 0 2px 8px rgba(60,77,122,.18); transform: translateY(-1px); }
.choice .c-eff { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); }

/* ---- tone-check phrase cards ---- */
.tone-grid { display: flex; flex-direction: column; gap: 8px; }
.tone-card { border-left: 4px solid var(--line); }
.tone-card.warm { border-left-color: var(--green); }
.tone-card.neutral { border-left-color: var(--trac-blue); }
.tone-card.sharp { border-left-color: var(--red); }

/* ---- rebase minigame ---- */
.rebase-wrap { padding: 8px 18px 18px; }
.rebase-grid { display: grid; gap: 8px; margin: 10px 0; }
.tile { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-family: var(--mono); font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .08s, background .12s; user-select: none; }
.tile:hover { transform: scale(1.04); }
.tile.conflict { background: #fbeaea; color: var(--red); border-color: #e0b4b4; }
.tile.resolved { background: #e9f5ea; color: var(--green); border-color: #b6dcb9; pointer-events: none; }
.rebase-status { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: center; }

/* ---- dev chat minigame ---- */
.chat-window { height: 240px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 6px; position: relative; }
.chat-scroll { padding: 8px 10px; }
.chat-line { font-size: 12.5px; line-height: 1.5; padding: 2px 0; opacity: .92; }
.chat-line b { color: var(--trac-blue-dark); }
.chat-target { color: var(--green) !important; font-weight: 600; }
.chat-postbar { display: flex; gap: 8px; margin-top: 10px; padding: 0 18px 18px; }
.chat-post { flex: 1; padding: 11px; border: none; border-radius: 5px; background: var(--green); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.chat-post:active { transform: scale(.98); }

/* ---- toast feedback ---- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; align-items: center; }
.toast { background: #2b2b28; color: #fff; padding: 7px 14px; border-radius: 20px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.3); animation: toastin .3s ease; }
.toast.good { background: #2f6b3f; } .toast.bad { background: #8a3030; } .toast.info { background: #3d4d7a; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* ---- intro ---- */
#intro { position: fixed; inset: 0; background: radial-gradient(ellipse at center, #3d4d7a, #20283f); display: flex; align-items: center; justify-content: center; z-index: 100; }
#intro.gone { display: none; }
.intro-card { text-align: center; color: #e8ebf5; max-width: 540px; padding: 30px; }
.intro-kicker { text-transform: uppercase; letter-spacing: 3px; font-size: 12px; opacity: .7; }
.intro-card h1 { font-size: 54px; margin: 8px 0 6px; letter-spacing: -1px; }
.intro-card h1 span { color: #f0c674; }
.intro-sub { font-size: 15px; line-height: 1.6; opacity: .9; }
#start-btn { margin: 24px 0 16px; padding: 13px 28px; font: inherit; font-size: 15px; font-weight: 700; border: none; border-radius: 6px; background: #f0c674; color: #2b2b28; cursor: pointer; transition: transform .1s, box-shadow .15s; }
#start-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(240,198,116,.35); }
.intro-foot { font-size: 12px; opacity: .55; line-height: 1.5; }

/* ---- ending / credits ---- */
.ending-modal { max-width: 680px; }
.ending-head { padding: 28px 24px; text-align: center; color: #fff; }
.ending-head .e-ach { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; opacity: .8; }
.ending-head .e-title { font-size: 32px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.ending-body { padding: 18px 24px; line-height: 1.65; font-size: 14.5px; }
.ending-body p { margin: 0 0 12px; }
.credits-note { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 12px; }
.credits { max-height: 320px; overflow-y: auto; border-top: 1px solid var(--line); background: #fbfaf5; padding: 10px 0; }
.credit-row { padding: 6px 22px; border-bottom: 1px solid #efece1; font-size: 12px; line-height: 1.5; animation: drop .2s ease; }
.credit-row .cr-meta { font-family: var(--mono); font-size: 10.5px; color: #a6a294; }
.credit-row .cr-author { font-weight: 700; }
.ending-actions { padding: 16px 24px 22px; text-align: center; }
.ending-actions button { padding: 11px 22px; border: none; border-radius: 6px; font: inherit; font-weight: 700; cursor: pointer; background: var(--trac-blue-dark); color: #fff; }
.final-comment { width: 100%; min-height: 70px; margin: 6px 0 12px; padding: 10px; font: inherit; border: 1px solid var(--line); border-radius: 5px; background: #fff; line-height: 1.5; overflow-y: auto; outline: none; }
.final-comment:focus { border-color: var(--trac-blue); box-shadow: 0 0 0 2px rgba(91,111,168,.15); }
.final-comment:empty:before { content: attr(data-placeholder); color: #a6a294; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  #hud { position: static; min-height: auto; border-left: none; border-top: 1px solid var(--line); }
}
