:root {
  --bg: #101218; --panel: #151821; --card: #1c2030; --line: #2c3245; --text: #e8ebf2; --dim: #98a1b3;
  --accent: #8cf0ff; --primary: #3f8fea; --danger: #e5534b; --good: #5fd06b; --gold: #ffcc40;
  --fire: #ec6a3f; --water: #3f8fea; --nature: #4fbf5c; --neutral: #9aa0ab;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas#game { position: fixed; left: 0; top: 0; display: block; outline: none; cursor: crosshair; }
#ui { position: fixed; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#notes { position: fixed; right: 44px; bottom: 8px; max-width: 300px; z-index: 5; }

.storage-note { background: #4a2b14; color: #ffd7a8; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
#fullscreen { position: fixed; right: 6px; bottom: 6px; z-index: 6; width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid var(--line); color: var(--dim); border-radius: 6px; font-size: 16px; }

.screen { position: absolute; inset: 0; }
.screen.center { display: flex; align-items: center; justify-content: center; }
.screen.dim { background: rgba(8, 10, 14, 0.72); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; max-width: 560px; }
.card.wide { width: 860px; max-width: 860px; }
.card.tall { height: 660px; display: flex; flex-direction: column; }
.card.split { max-height: 690px; display: flex; flex-direction: column; }
.scrollbody { overflow-y: auto; min-height: 0; flex: 1; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding-right: 8px; margin-top: 6px; }
.scrollbody h3:first-child, .disclosure > :first-child { margin-top: 8px; }
.card.title { text-align: center; min-width: 360px; }
.card.menu { min-width: 340px; }
h1 { margin: 0 0 10px; font-size: 28px; }
h1.logo { font-size: 44px; letter-spacing: 1px; }
h2 { margin: 0 0 12px; font-size: 22px; }
h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
p { margin: 6px 0; }
.lead { font-size: 16px; }
.note { color: var(--dim); font-size: 13px; }
.warn { background: #3d2c10; color: #ffd27a; padding: 6px 10px; border-radius: 6px; }
ul { margin: 4px 0 8px; padding-left: 20px; }
li { margin: 3px 0; }
a { color: var(--accent); }
.buttons { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.buttons.column { flex-direction: column; }
button { font: inherit; color: var(--text); background: #2a3044; border: 1px solid #3a4260; border-radius: 7px;
  padding: 9px 16px; cursor: pointer; }
button:hover:not(:disabled) { background: #343b54; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--primary); border-color: #5aa2f0; color: #fff; font-weight: 600; }
button.primary:hover { background: #4f9cf0; }
button.danger { background: #5a2626; border-color: #7a3434; }
button.big { font-size: 18px; padding: 12px 26px; }
.check { display: block; margin: 10px 0; }

/* Between runs */
.between { display: grid; grid-template-columns: 1fr 1.15fr; gap: 28px; padding: 34px 50px; background: var(--bg); }
.between .col { overflow: hidden; }
.between .wallet { font-size: 26px; font-weight: 700; color: var(--gold); margin: 14px 0; }
.summary { padding: 12px 16px; max-width: none; }
.summary .big { font-size: 17px; font-weight: 600; }
.newbest { color: var(--gold, #ffd24a); font-weight: 700; font-size: 15px; margin: 6px 0 0; }
.best { color: var(--dim); font-size: 14px; font-weight: 600; }
.rack { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; min-width: 104px; }
.upgrades { display: flex; flex-direction: column; min-height: 0; }
.between { grid-template-rows: 100%; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.tab { padding: 6px 14px; border-radius: 7px 7px 0 0; background: #20263a; }
.tab.on { background: var(--primary); border-color: #5aa2f0; color: #fff; font-weight: 600; }
.uplist { overflow-y: scroll; min-height: 0; flex: 1; padding-right: 8px; display: flex; flex-direction: column; gap: 6px; }
.uplist::-webkit-scrollbar { width: 10px; }
.uplist::-webkit-scrollbar-thumb { background: #3a4260; border-radius: 5px; }
.uplist::-webkit-scrollbar-track { background: #171a24; }
.upsection { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.upsection h3 { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.elements { display: flex; gap: 6px; align-items: center; }
.elements .note { margin-right: 6px; }
.elbtn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; }
.elbtn.on { border-color: var(--gold); background: #3a3420; }
.slot.on { border-color: var(--gold); }
.up { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.up .upname { grid-column: 1; }
.up .note { grid-column: 1; margin: 0; }
.up button { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 110px; }
.lvl { color: var(--dim); font-size: 13px; }

/* Element chips: colour plus a glyph shape */
.chip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; }
.chip.big { width: 26px; height: 26px; }
.glyph { display: block; width: 10px; height: 10px; background: rgba(10, 12, 18, 0.8); }
.glyph.g1 { clip-path: polygon(50% 0, 100% 90%, 0 90%); }
.glyph.g2 { border-radius: 50%; }
.glyph.g3 { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

/* Picks */
.card.picks { max-width: 900px; text-align: center; }
.pickrow { display: flex; gap: 14px; justify-content: center; }
.pickcard { width: 230px; min-height: 170px; text-align: left; display: flex; flex-direction: column; gap: 4px;
  background: #242a3d; border: 2px solid #3d4766; padding: 14px; position: relative; }
.pickcard.sel { border-color: var(--gold); background: #2d3550; box-shadow: 0 0 0 2px rgba(255,204,64,0.35); }
.pickcard.skip { width: 150px; }
.pickcard h3 { margin: 0; font-size: 18px; color: var(--text); }
.pickcard .lvl { color: var(--gold); font-weight: 600; }

/* Settings */
.settings { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.settings-head { display: flex; gap: 10px; align-items: center; }
.settings-head h2 { margin: 0 auto 0 0; }
.settings-search { font: inherit; width: 260px; padding: 8px 10px; border-radius: 7px; border: 1px solid #3a4260;
  background: #12151e; color: var(--text); }
.settings-list { overflow-y: auto; flex: 1; padding-right: 6px; margin-top: 6px; }
.sgroup { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: #191d2b; }
.sgroup summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
.badge { margin-left: 10px; font-size: 12px; color: var(--gold); font-weight: 500; }
.srow { display: grid; grid-template-columns: 1fr 360px; align-items: center; padding: 5px 12px; border-top: 1px solid #23283a; }
.srow.changed { background: #2a2614; }
.srow.changed .slabel::before { content: "● "; color: var(--gold); }
.slabel { font-size: 14px; }
.sdef { color: var(--dim); font-size: 12px; margin-left: 8px; }
.scontrol { display: grid; grid-template-columns: 1fr 64px 64px; gap: 8px; align-items: center; }
.scontrol input[type=range] { width: 100%; accent-color: var(--accent); }
.scontrol input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.svalue { text-align: right; font-variant-numeric: tabular-nums; }
.sreset { padding: 3px 8px; font-size: 12px; }

/* Replay */
.replay-bar { position: fixed; left: 8px; top: 7px; right: 300px; display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap; z-index: 10; }
.replay-bar button { padding: 4px 10px; font-size: 13px; }
.rinfo { color: var(--dim); font-size: 13px; margin-left: 8px; }
.rstatus { font-weight: 700; margin-left: 8px; }
.rstatus.good { color: var(--good); }
.rstatus.bad { color: var(--danger); }
.rwarn { color: #ffd27a; font-size: 13px; width: 100%; }
.replay-side { position: fixed; right: 0; top: 0; bottom: 0; width: 290px; overflow-y: auto; background: rgba(16,18,24,0.94);
  border-left: 1px solid var(--line); padding: 8px 10px; z-index: 10; font-size: 12px; }
.replay-side h3 { margin: 4px 0 8px; }
.tl { padding: 3px 4px; border-radius: 4px; cursor: pointer; color: var(--dim); display: flex; gap: 6px; }
.tl.past { color: var(--text); }
.tl.now { background: #2a3044; }
.tlt { color: #6b7488; font-variant-numeric: tabular-nums; flex: 0 0 46px; }
.tl-n_death, .tl-run_quit { color: #ff8a80; }

/* Tutorial */
#tut { position: fixed; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; pointer-events: none; z-index: 4; }
#tut > * { pointer-events: auto; }
.tut-dim { position: absolute; border: 2px solid var(--gold); border-radius: 10px; pointer-events: none !important;
  box-shadow: 0 0 0 3000px rgba(6, 8, 12, 0.6); }
.tut-block { position: absolute; }
.tut-card { position: absolute; left: 300px; width: 680px; background: #1d2338; border: 2px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.tut-card.place-top { top: 14px; }
.tut-card.place-bottom { bottom: 14px; }
.tut-card.place-middle { top: 165px; }
.tut-card.place-left { left: 40px; width: 520px; bottom: 20px; }
.tut-card h3 { margin: 0 0 4px; color: var(--gold); }
.tut-card p { margin: 0 0 6px; font-size: 15px; }
.tut-diagram { width: 320px; height: 140px; display: block; margin: 4px 0; background: #141826; border-radius: 6px; }
.tut-buttons { display: flex; gap: 8px; margin-top: 6px; }
.tut-buttons button { padding: 6px 12px; font-size: 14px; }
.tut-buttons.tut-point { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: 8px; animation: tutpulse 1s infinite; }
@keyframes tutpulse { 50% { outline-color: rgba(255,204,64,0.25); } }
.tut-guide { display: grid; grid-auto-flow: column; gap: 6px; align-items: center; justify-content: start; margin: 4px 0; }
.tut-guide.keys { grid-template-columns: repeat(3, 34px); grid-auto-flow: row; }
.tut-key { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 6px;
  border: 2px solid #4a5370; border-radius: 6px; background: #252b40; font-weight: 700; }
.tut-key.wide { min-width: 90px; }
.tut-key.lit, .tut-mb.lit, .tut-stick.lit { background: var(--gold); color: #1a1400; border-color: #fff2b0; }
.tut-mouse { display: inline-flex; width: 44px; height: 58px; border: 2px solid #4a5370; border-radius: 20px 20px 18px 18px; overflow: hidden; }
.tut-mb { flex: 1; height: 24px; border-bottom: 2px solid #4a5370; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: #252b40; }
.tut-mb + .tut-mb { border-left: 2px solid #4a5370; }
.tut-stick { display: inline-flex; align-items: center; padding: 4px 10px; border: 2px solid #4a5370; border-radius: 16px; background: #252b40; }
.elbtn.demo { outline: 3px solid var(--gold); }
.ask .buttons { justify-content: center; }
/* Clicks go through a tutorial card to the game, except on its buttons. */
#tut > .tut-card { pointer-events: none; }
.tut-card button { pointer-events: auto; }

/* Touch controls */
#touchui { position: fixed; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; pointer-events: none; z-index: 3; }
.touch-controls > * { pointer-events: auto; touch-action: none; }
.tc-field { position: absolute; }
.tc-stick { position: absolute; border-radius: 50%; background: rgba(140, 240, 255, 0.08); border: 2px solid rgba(140, 240, 255, 0.4);
  display: flex; align-items: center; justify-content: center; }
.tc-knob { width: 56px; height: 56px; border-radius: 50%; background: rgba(140, 240, 255, 0.45); pointer-events: none; }
.tc-label { position: absolute; bottom: -22px; font-size: 13px; color: var(--dim); white-space: nowrap; pointer-events: none; }
.tc-btn { position: absolute; width: 104px; height: 64px; border-radius: 14px; font-weight: 700; font-size: 16px; touch-action: none; }
.tc-btn.dash { left: 1022px; top: 450px; }
.tc-btn.catch { left: 1150px; top: 450px; background: #1f4a30; border-color: #2f7a4a; }
.tc-btn.pause { left: 1226px; top: 8px; width: 46px; height: 40px; }
.tc-btn.on { background: var(--gold); color: #1a1400; }
#rotate { display: none; }
@media (orientation: portrait) {
  body.touch-mode #rotate { display: flex; position: fixed; inset: 0; z-index: 30; background: var(--bg); color: var(--text);
    align-items: center; justify-content: center; text-align: center; padding: 24px; font-size: 22px; }
}

/* Feedback */
#modal { position: fixed; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; pointer-events: none; z-index: 8; }
#modal > * { pointer-events: auto; }
.fb-buttons { display: flex; gap: 8px; margin-top: 14px; }
.fb-buttons button { padding: 5px 10px; font-size: 13px; background: #222839; }
.fb-buttons.wide button { flex: 1; }
.fb-card { max-height: 700px; overflow-y: auto; padding: 18px 24px; }
.fb-card h2 { margin-bottom: 4px; }
.fb-label { display: block; font-weight: 600; margin: 8px 0 4px; }
.fb-q { display: block; position: relative; }
.fb-q textarea { width: 100%; font: inherit; color: var(--text); background: #12151e; border: 1px solid #3a4260; border-radius: 7px;
  padding: 6px 8px; resize: vertical; }
.fb-count { position: absolute; right: 6px; top: 8px; font-size: 12px; color: var(--dim); }
.fb-rating, .fb-cats { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fb-rating .fb-label, .fb-cats .fb-label { width: 100%; }
.fb-star { width: 42px; }
.fb-star.on, .fb-cat.on, .fb-star.on:hover, .fb-cat.on:hover { background: var(--gold) !important; color: #1a1400; border-color: #fff2b0; }
.fb-status { min-height: 20px; font-weight: 600; }
.fb-prompt { text-align: center; }
