:root {
  --bg: #0b0f1a; 
  --panel: #121a2b; 
  --panel2: #18223a; 
  --line: #243251;
  --text: #e8edf8; 
  --muted: #8d9bb8; 
  --gold: #ffc233; 
  --violet: #7c6cff;
  --green: #2fd18b; 
  --red: #ff5d6c; 
  --radius: 14px;

  --msg-success-bg: #286f50;
  --msg-error-bg: #71242c;
  --msg-info-bg: #272062;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1100px 520px at 12% -8%, #1d2652 0, transparent 60%), var(--bg);
  color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); letter-spacing: -.02em; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
.muted { color: var(--muted); }
small { font-size: .82rem; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 1rem; }
main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }

/* top bar */
.topbar { border-bottom: 1px solid var(--line); background: rgba(11, 15, 26, .85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.topbar .wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: .7rem; padding-bottom: .7rem; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); letter-spacing: -.02em; }
.brand span { color: var(--gold); }
.brand img { height: 40px; width: auto; display: block; }
.nav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-left: auto; font-size: .95rem; }
.nav a, .nav .link { color: var(--text); }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem; font-weight: 700; color: var(--gold); }
form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
button.link:hover { color: var(--text); text-decoration: underline; }

.banner { background: #3a2f0d; color: #ffe39a; text-align: center; font-size: .85rem; padding: .35rem 1rem; }

/* messages */
.msg { border-radius: 10px; padding: .7rem 1rem; margin-bottom: .8rem; border: 1px solid var(--line); background: var(--panel); }
.msg.success {background: var(--msg-success-bg); border-color: var(--msg-success-bg); }
.msg.error { background: var(--msg-error-bg); border-color: var(--msg-error-bg); }
.msg.info { background: var(--msg-info-bg); border-color: var(--msg-info-bg); }

/* buttons */
.btn, button.btn {
  display: inline-block; background: var(--gold); color: #1a1400; border: 0; border-radius: 10px;
  padding: .65rem 1.2rem; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.big { padding: .9rem 1.8rem; font-size: 1.1rem; }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* "processing" spinner, added by buttons.js to any button/link while it is working */
.btn-spinner {
  display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -.15em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: btnspin .7s linear infinite;
}
.is-loading { cursor: progress; pointer-events: none; }
.is-loading .btn-label { margin-left: .5em; }
button.is-loading:disabled, .btn.is-loading:disabled { opacity: .85; cursor: progress; }
.btn.is-loading, .opt.is-loading { display: inline-flex; align-items: center; justify-content: center; }
.opt.is-loading { display: flex; width: 100%; }
button.link.is-loading { display: inline-flex; align-items: center; opacity: .8; }
a.btn.is-loading { opacity: .85; }
.dg-tool.is-loading, .dg-tool.is-loading:disabled { opacity: 1; }
@keyframes btnspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation-duration: 1.6s; } }

/* hero + cards */
.hero { padding: 2rem 0 1rem; }
.hero p { max-width: 620px; color: var(--muted); font-size: 1.1rem; }
.hero .btn { margin-right: .5rem; margin-top: .5rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card {
  display: block; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; transition: transform .12s, border-color .12s;
}
a.card:hover { transform: translateY(-2px); border-color: var(--violet); text-decoration: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.tag { background: var(--panel2); border-radius: 6px; padding: .1rem .55rem; font-size: .8rem; color: var(--muted); }
.badge { border-radius: 6px; padding: .1rem .55rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.badge.open { background: #123b2c; color: var(--green); }
.badge.settled { background: #2b2460; color: #b6adff; }
.badge.cancelled { background: #4a1d24; color: var(--red); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .8rem 0; }
.stats small { display: block; color: var(--muted); }
.stats b { font-size: 1.1rem; }
.two { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }

/* forms */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field input:not([type=checkbox]), .field select, .input {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: .65rem .8rem; font: inherit;
}
.field input:focus, .input:focus { outline: 2px solid var(--violet); border-color: transparent; }
.check { display: flex !important; gap: .6rem; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: .3rem; }
.err { color: var(--red); font-size: .88rem; margin-top: .2rem; }
.errorlist { margin: 0; padding-left: 1rem; color: var(--red); }
.narrow { max-width: 480px; margin: 0 auto; }

/* tables: all tables use the shared data grid look, see datagrid.css */
.pos { color: var(--green); } .neg { color: var(--red); }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 1.2rem 0; }

/* game */
.hud { display: flex; justify-content: space-between; align-items: center; font-size: 1.2rem; margin-bottom: .6rem; }
.hud b { color: var(--gold); font-size: 1.5rem; }
#timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-bottom: 1.2rem; }
#barfill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .2s linear; }
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; min-height: 260px; text-align: center; }
.stage.good { border-color: var(--green); }
.stage.bad { border-color: var(--red); }
.q { font-size: 1.5rem; margin: .8rem 0 1.2rem; }
.big { font-size: clamp(2.2rem, 9vw, 3.6rem); margin: 1rem 0; font-variant-numeric: tabular-nums; }
.opts { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .opts { grid-template-columns: 1fr; } }
.opt { background: var(--panel2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: .9rem; font: inherit; font-size: 1.05rem; cursor: pointer; }
.opt:hover { border-color: var(--violet); }
.opt.correct { border-color: var(--green); background: #123b2c; }
.opt.wrong { border-color: var(--red); background: #4a1d24; }
.tiles { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }
.tile { background: var(--gold); color: #1a1400; font-weight: 800; font-size: 1.6rem; width: 2.6rem; height: 2.9rem; display: grid; place-items: center; border-radius: 8px; }
.hint { color: var(--muted); }
.answer-row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; max-width: 460px; margin: 1rem auto 0; }
.answer-row .input { flex: 1 1 180px; font-size: 1.3rem; text-align: center; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---- newer games: emoji, riddle, typing, memory --------------------------------------- */
.big.emoji { font-size: clamp(2.6rem, 14vw, 4.6rem); letter-spacing: .15em; }
.typing-text { font-size: 1.25rem; line-height: 1.6; text-align: left; margin: 1rem auto; max-width: 560px; word-break: break-word; }
.typed-ok { color: var(--green); }
.typed-bad { color: var(--red); background: #4a1d24; border-radius: 3px; }
.typed-rest { color: var(--muted); }
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; max-width: 380px; margin: 1rem auto 0; }
.mcard { aspect-ratio: 1 / 1; font-size: clamp(1.6rem, 9vw, 2.4rem); background: var(--panel2); color: var(--muted); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; display: grid; place-items: center; padding: 0; font-family: inherit; }
.mcard:hover { border-color: var(--violet); }
.mcard.up { background: #2b2460; color: var(--text); border-color: var(--violet); cursor: default; }
.mcard.matched { background: #123b2c; border-color: var(--green); }
