/* Simteractiv */
:root {
  --bg: #FAF6F1; --card: #FFFFFF; --ink: #2B2622; --ink2: #6B635C; --line: #E7DFD6;
  --accent: #E4572E; --accent-d: #C2431F; --blue: #2E86AB; --green: #2F9A55; --red: #C8364A; --soft: #F3ECE4;
  --r: 12px; --shadow: 0 1px 2px rgba(43,38,34,.06), 0 4px 16px rgba(43,38,34,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--accent-d); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h3 { font-size: 1.05rem; color: var(--ink2); margin-top: 1.4em; }
p { margin: .5em 0; }
small, .muted { color: var(--ink2); }
.muted { font-size: .92rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* brand */
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand svg { width: 28px; height: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.topbar nav a, .topbar nav button { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; background: none; border: 0; cursor: pointer; font: inherit; }
.topbar nav a:hover, .topbar nav button:hover, .topbar nav a.on { background: var(--soft); }

/* forms and buttons */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: .65rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228,87,46,.15); }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .62rem 1.1rem; border-radius: 10px; border: 0; background: var(--accent); color: #fff;
  font-weight: 650; cursor: pointer; text-decoration: none; min-height: 44px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-d); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover, button.ghost:hover { background: var(--soft); }
button.wide, .btn.wide { white-space: normal; text-align: center; line-height: 1.25; }
.btn.dark, button.dark { background: var(--ink); }
.btn.green, button.green { background: var(--green); }
button.link, .link { background: none; border: 0; color: var(--accent-d); padding: 0 .2rem; min-height: 0; font-weight: 600; text-decoration: underline; cursor: pointer; }
.wide { width: 100%; }
label.f { display: block; margin: .8rem 0; font-weight: 600; font-size: .95rem; }
label.f > input, label.f > select { margin-top: .3rem; font-weight: 400; }
label.chk { display: flex; gap: .5rem; align-items: center; margin: .6rem 0; font-size: .95rem; }
.row { display: flex; gap: .5rem; margin: .8rem 0; }
.row input { flex: 1; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; margin: .6rem 0; }
.row3 input { padding: .5rem; }
.row3 button { grid-column: 1 / -1; }
.err { color: var(--red); font-weight: 600; }
.ok { color: var(--green); }
.win { color: var(--green); font-weight: 700; font-size: 1.1rem; }
.warn { color: var(--red); font-weight: 700; }
.note { background: var(--soft); padding: .5rem .7rem; border-radius: 8px; font-size: .95rem; }

/* cards and layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.narrow { max-width: 480px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.gcard { cursor: pointer; transition: transform .12s, border-color .12s; display: flex; flex-direction: column; gap: .4rem; }
.gcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.gcard .tag { font-size: .8rem; font-weight: 700; color: var(--accent-d); text-transform: uppercase; letter-spacing: .04em; }
.gcard h3 { margin: 0; color: var(--ink); font-size: 1.15rem; }
.gcard p { font-size: .93rem; color: var(--ink2); margin: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { color: var(--ink2); font-weight: 600; font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--soft); color: var(--ink2); }
.badge.live { background: #E3F4E9; color: var(--green); }
.badge.pend { background: #FFF1DB; color: #9A6200; }
.badge.blk { background: #FBE3E6; color: var(--red); }
.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; justify-content: center; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .9rem; min-width: 110px; text-align: center; }
.stats span { display: block; font-size: .78rem; color: var(--ink2); text-transform: uppercase; letter-spacing: .03em; }
.stats b { font-size: 1.35rem; }

/* charts */
svg.chart { width: 100%; height: auto; display: block; margin: .4rem 0 1rem; }
svg.chart .grid { stroke: #EEE7DF; stroke-width: 1; }
svg.chart .axis { stroke: #B9AFA5; stroke-width: 1.5; }
svg.chart .vline { stroke: #B9AFA5; stroke-width: 1.5; stroke-dasharray: 4 4; }
svg.chart text { font-family: inherit; }
svg.chart .tick { font-size: 12px; fill: #6B635C; }
svg.chart .lab { font-size: 13px; fill: #6B635C; font-weight: 600; }
svg.chart .val { font-size: 13px; fill: #2B2622; font-weight: 700; }
svg.chart .hl { font-size: 12px; fill: #2B2622; font-weight: 700; }

/* market */
.role { border-radius: 12px; padding: .8rem 1rem; margin: .6rem 0; color: #fff; }
.role span { display: block; font-size: .8rem; font-weight: 800; letter-spacing: .08em; opacity: .9; }
.role b { display: block; font-size: 1.4rem; }
.role small { color: #fff; opacity: .92; }
.role small b, .role small strong { display: inline; font-size: inherit; }
.role.buy { background: var(--blue); }
.role.sell { background: var(--accent); }
.book { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; margin: 1rem 0; text-align: center; }
.book h4 { margin: 0 0 .3rem; font-size: .8rem; color: var(--ink2); text-transform: uppercase; }
.book > div > div { padding: .25rem; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.book .bid { background: #E1F0F6; color: #1D5F7B; }
.book .ask { background: #FBE6DE; color: #9B3417; }
.book.big { font-size: 1.6rem; max-width: 760px; margin: 1rem auto; }
.book.big h4 { font-size: .9rem; }
.accept { background: var(--green); margin: .3rem 0; }
.accept:hover { background: #237A42; }
.meter { position: relative; height: 34px; background: var(--soft); border-radius: 8px; overflow: hidden; margin: .7rem 0; }
.meter div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #8CC7DC, #2E86AB); }
.meter span { position: relative; display: block; padding: .35rem .7rem; font-size: .9rem; font-weight: 700; color: var(--ink); }

/* student */
.st-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.st-head h1 { font-size: 1.15rem; margin: 0; }
.pill { display: inline-block; background: var(--ink); color: #fff; border-radius: 99px; padding: .15rem .65rem; font-size: .8rem; font-weight: 700; }
.pill.play { background: var(--green); }
.me { display: flex; justify-content: space-between; font-size: .92rem; color: var(--ink2); border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .7rem; }
.lead { font-size: 1.1rem; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: 99px; font-size: .92rem; z-index: 50; }
.codebox input { text-transform: uppercase; text-align: center; font-size: 2rem; letter-spacing: .3em; font-weight: 800; }

/* teacher runner */
.runbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.runbar .ttl { font-weight: 800; font-size: 1.05rem; }
.runbar .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 800; font-size: 1.2rem; letter-spacing: .12em; background: var(--soft); padding: .1rem .5rem; border-radius: 6px; }
.runbar .sp { flex: 1; }
.runbar .ctrls { display: flex; gap: .4rem; flex-wrap: wrap; }
.runwrap { display: grid; grid-template-columns: 320px 1fr; min-height: calc(100vh - 60px); }
.runwrap aside { border-right: 1px solid var(--line); background: #FCFAF7; padding: 1rem; overflow-y: auto; max-height: calc(100vh - 60px); position: sticky; top: 60px; }
.runwrap aside details { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.runwrap aside summary { font-weight: 700; cursor: pointer; }
.runwrap aside label.f { margin: .5rem 0; font-size: .88rem; }
#stage { padding: 1.2rem 1.6rem 3rem; background: var(--bg); overflow-x: hidden; }
#stage:fullscreen { padding: 2rem 3rem; font-size: 1.25rem; overflow-y: auto; }
.plist { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.plist li { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: .1rem .55rem; font-size: .85rem; }
.plist li.done { background: #E3F4E9; border-color: #BFE3CB; }
.plist li.paper { border-style: dashed; }
.big-prompt { text-align: center; padding: 1.5rem 1rem; }
.big-prompt h2 { font-size: 2.1rem; }
.big-prompt p { font-size: 1.25rem; color: var(--ink2); }
.join { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; max-width: 900px; margin: 1rem auto; }
.join .qr svg { width: 260px; height: 260px; background: #fff; border-radius: 12px; padding: 6px; }
.join .big { font-size: 4.2rem; font-weight: 900; letter-spacing: .15em; font-family: ui-monospace, Menlo, Consolas, monospace; line-height: 1; }
.join .url { font-size: 1.5rem; font-weight: 700; }
.names { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: 1rem 0; }
.names span { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: .2rem .8rem; font-weight: 600; }
.rules { font-size: 1.05rem; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; margin: .5rem 0; }
.pgrid .btn { grid-column: 1 / -1; }
.pin { display: flex; align-items: center; gap: .3rem; font-size: .85rem; font-weight: 700; }
.pin span { min-width: 2.6rem; }
.pin input { min-height: 36px; padding: .3rem .5rem; }
ol.mini { font-size: .9rem; padding-left: 1.2rem; }
.overlay { position: fixed; inset: 0; background: rgba(43,38,34,.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 1rem; }
.overlay .card { max-width: 980px; width: 100%; max-height: 92vh; overflow: auto; }
.lead-board { max-width: 520px; margin: 1rem auto; }

/* footer, legal */
.foot { text-align: center; font-size: .78rem; color: var(--ink2); padding: 1.5rem 1rem; }
.foot a { color: var(--ink2); margin: 0 .4rem; }
.legal { max-width: 760px; }
.legal h2 { margin-top: 1.6em; font-size: 1.2rem; }
.cookie { position: fixed; bottom: 12px; left: 12px; right: 12px; max-width: 560px; margin: 0 auto; background: var(--ink); color: #fff; padding: .7rem .9rem; border-radius: 12px; font-size: .88rem; display: flex; gap: .8rem; align-items: center; z-index: 60; }
.cookie a { color: #FFD3C2; }
.cookie button { min-height: 36px; padding: .35rem .9rem; }

/* home */
.hero { text-align: center; padding: 3rem 1rem 1.5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.02em; }
.hero p { font-size: 1.15rem; color: var(--ink2); max-width: 640px; margin: .6rem auto; }
.joinbox { max-width: 420px; margin: 1.5rem auto; }

@media (max-width: 860px) {
  .runwrap { grid-template-columns: 1fr; }
  .runwrap aside { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .join { grid-template-columns: 1fr; text-align: center; }
  .join .qr svg { width: 200px; height: 200px; }
  .join .big { font-size: 3rem; }
  #stage { padding: 1rem; }
}
@media print { .noprint { display: none !important; } }

.credit { font-size: .78rem; color: var(--ink2); margin-top: 1.2rem; line-height: 1.4; }
#stage .credit { text-align: center; border-top: 1px solid var(--line); padding-top: .8rem; margin-top: 2rem; }
/* wide tables scroll inside the phone card instead of overflowing it */
.narrow .card table { display: block; max-width: 100%; overflow-x: auto; }
.narrow .card table td, .narrow .card table th { white-space: nowrap; }
