/* The game, shared by the site (index.html) */
:root {
  --bg: #e9e9e6; --paper: #f8f8f7; --ink: #1d1c17; --muted: #55534b; --blue: #2456d6; --red: #d8361f; --line: #d9d6cf;
  --display: "Bricolage Grotesque", system-ui, sans-serif; --text: "Bricolage Grotesque", system-ui, sans-serif;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

/* rows: board and controls column, the docked thinking panel (empty unless open), the controls row.
   Row spacing sits on the rows themselves so an empty thinking row adds no gap. */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "stage panel" "think think" "under under"; gap: 0 22px; margin-top: 22px; align-items: stretch; }
.layout > .thinkrow { grid-area: think; }
/* open: a white card the width of the layout, the dark panel centred on it */
.layout > .thinkrow:has(#think:not([hidden])) { margin-top: 18px; background: var(--paper); border-radius: 22px; padding: 18px; }
.layout > .stage { grid-area: stage; }
.layout > .panel { grid-area: panel; display: flex; flex-direction: column; }
/* the gauge keeps its natural height: if the board's card grows (a docked thinking
   panel), the column simply ends earlier instead of padding the gauge */
.layout > .panel > .gaugebox { display: flex; flex-direction: column; }
.layout > .under { grid-area: under; margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px 22px; }
.under .block { display: grid; align-content: center; }
.under .toggles { margin-top: 10px; }

/* the board */
.stage { position: relative; background: var(--paper); border-radius: 22px; overflow: hidden; }
/* The board grows to the height of the control column beside it; a docked
   thinking panel takes its room from the board. */
.stage { display: flex; flex-direction: column; }
#board { display: block; width: 100%; flex: 1 1 0; height: 0; min-height: clamp(460px, calc(100svh - 240px), 700px); }
#start { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: var(--paper); transition: opacity .5s, visibility .5s; }
#start.gone { opacity: 0; visibility: hidden; }
.stage.xray-on, #board.xray { background: #fbf6f4; }
/* --below is the height of the thinking panel when it docks under the board */
#say { position: absolute; left: 190px; right: 16px; bottom: calc(16px + var(--below, 0px)); width: fit-content; margin-inline: auto; transform: translateY(14px); opacity: 0; max-width: 560px; z-index: 3; font-size: 15px;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 500; text-align: center;
  transition: opacity .35s, transform .45s var(--spring); pointer-events: none; }
#say.in { opacity: 1; transform: none; }
.genbadge { position: absolute; left: 18px; bottom: calc(16px + var(--below, 0px)); font: 600 15px var(--text); color: var(--muted); }
.genbadge b { font: 800 1.6rem var(--display); color: var(--ink); margin-left: 4px; }
.lines { display: grid; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lines div { display: grid; grid-template-columns: 1fr minmax(96px, 55%); align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.lines canvas { width: 100%; height: 28px; }

/* controls */
.panel { display: grid; gap: 16px; }
.block { background: var(--paper); border-radius: 22px; padding: 18px; }
.block h2 { font: 800 1.15rem var(--display); letter-spacing: -0.01em; margin-bottom: 12px; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules button { text-align: left; font: 600 15px/1.25 var(--text); color: var(--ink); background: var(--bg); border: 0; border-radius: 16px;
  padding: 14px 14px 16px; min-height: 92px; cursor: pointer; transition: transform .35s var(--spring), background .2s, color .2s; }
.rules button span { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 6px; transition: color .2s; }
.rules button:hover { transform: translateY(-3px); }
.rules button:active { transform: scale(.96); }
.rules button[aria-pressed="true"] { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.rules button[aria-pressed="true"] span { color: #c9c6bd; }

.dialrow { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; transition: opacity .3s, filter .3s; }
#dial.off .dialrow { opacity: .35; filter: grayscale(1); pointer-events: none; }
#knob { --turn: 0deg; width: 120px; height: 120px; border-radius: 50%; background: var(--bg); position: relative; cursor: grab; touch-action: none; }
#knob::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--ink); transform: rotate(var(--turn)); transition: transform .12s; }
#knob::after { content: ""; position: absolute; left: 50%; top: 22px; width: 6px; height: 26px; margin-left: -3px; border-radius: 3px; background: var(--paper);
  transform-origin: 3px 38px; transform: rotate(var(--turn)); transition: transform .12s; }
#knob:active { cursor: grabbing; }
#knob:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
.dialval { font: 800 2.2rem var(--display); }
.dialrow p { font-size: 14px; color: var(--muted); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--bg); padding: 5px; border-radius: 14px; }
.seg button { border: 0; background: transparent; font: 600 13px/1.2 var(--text); padding: 10px 6px; border-radius: 10px; cursor: pointer; color: var(--muted); transition: background .2s, color .2s, transform .3s var(--spring); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); transform: scale(1.03); }

.actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.big { border: 0; border-radius: 999px; font: 600 17px var(--text); padding: 16px; cursor: pointer; transition: transform .3s var(--spring), background .2s; }
#play { background: var(--blue); color: #fff; }
#play[aria-pressed="true"] { background: var(--ink); }
#reset { background: var(--bg); color: var(--ink); }
.big:hover { transform: translateY(-2px); } .big:active { transform: scale(.96); }
.toggles { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 12px; }
#xray { border: 0; border-radius: 999px; padding: 12px 16px; font: 600 15px var(--text); background: var(--bg); color: var(--ink); cursor: pointer; transition: background .2s, color .2s; }
#xray[aria-pressed="true"] { background: var(--red); color: #fff; }
.speed { display: flex; gap: 4px; }
.speed button { border: 0; background: var(--bg); border-radius: 10px; padding: 10px 11px; font: 600 13px var(--text); cursor: pointer; color: var(--muted); }
.speed button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.gaugebox { text-align: center; }
#gauge { width: 100%; height: 150px; display: block; }
.gaugeno { font: 800 2.4rem/1 var(--display); margin-top: 10px; font-variant-numeric: tabular-nums; }
.gaugesay { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 6px; min-height: 1.4em; }
/* the dial's labels are placed by the code that draws it (drawGauge), so each sits
   on its own point of the arc: the two ends below, the zero mark above */
.dial { position: relative; padding-bottom: 20px; }
.gl { position: absolute; transform: translateX(-50%); font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; line-height: 1; }
.gl.gl-zero { transform: translate(-50%, -100%); }

#think { position: absolute; left: 16px; top: 64px; width: min(320px, calc(100% - 32px)); z-index: 3; background: var(--ink); color: var(--paper); border-radius: 18px; padding: 16px 18px; }
#think.right { left: auto; right: 16px; }
/* docked under the board: a centred card, narrow enough that each option sits near its number */
#think.below { position: relative; left: auto; right: auto; top: auto; width: 100%; max-width: 600px; margin: 0 auto; }
#think h3 { font: 800 1.1rem var(--display); }
#think p { font-size: 14px; color: #cfcdc5; margin-top: 4px; }
#think ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
#think li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 14px; align-items: baseline; }
#think li span:nth-child(2) { color: #cfcdc5; }
#think .kept { color: #8fb0ff; } #think .rej { color: #8f8c84; font-weight: 500; }
#think .tail { margin-top: 10px; }
.hint { position: absolute; left: 50%; bottom: calc(16px + var(--below, 0px)); transform: translateX(-50%); font-size: 14px; color: var(--muted); pointer-events: none; transition: opacity .3s; }
#say.in ~ .hint { opacity: 0; }
#board { cursor: pointer; }

#levels { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
#levels button { border: 0; background: var(--paper); border-radius: 999px; padding: 10px 16px; font: 600 15px var(--text); color: var(--ink); cursor: pointer; display: flex; gap: 8px; align-items: center; transition: transform .3s var(--spring), background .2s, color .2s; }
#levels button i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 13px; }
#levels button em { font-style: normal; font-size: 12px; color: var(--blue); }
#levels button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#levels button[aria-pressed="true"] i { background: var(--blue); color: #fff; }
#levels button:hover { transform: translateY(-2px); }
#brief { background: var(--bg); border-radius: 22px; padding: 26px 28px; max-width: 440px; text-align: left; display: grid; gap: 10px; border: 0; }
#brief h3, #result h3 { font: 800 1.7rem/1.05 var(--display); letter-spacing: -0.03em; }
#brief p { color: var(--ink); margin: 0; }
#brief .goal { color: var(--blue); font-weight: 600; }
#brief small { color: var(--muted); font-size: 13px; }
.go { background: var(--blue) !important; color: #fff !important; padding: 14px 28px; justify-self: start; }
#tracker { position: absolute; right: 16px; top: 16px; background: var(--paper); border-radius: 16px; padding: 10px 14px; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; }
#tracker b { font: 800 1.5rem var(--display); grid-row: span 2; }
#tracker .segs { display: flex; gap: 4px; }
#tracker .segs span { width: 14px; height: 10px; border-radius: 3px; background: var(--bg); transition: background .25s, transform .3s var(--spring); }
#tracker .segs span.on { background: var(--blue); transform: scaleY(1.3); }
#tracker small { color: var(--muted); font-size: 13px; }
#result { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(247,245,240,.55); }
#result > div { background: var(--ink); color: var(--paper); border-radius: 22px; padding: 26px 28px; max-width: 460px; display: grid; gap: 12px; animation: pop .55s var(--spring) both; }
#result p { color: #d8d5cc; }
#result .row { display: flex; gap: 10px; flex-wrap: wrap; }
#result .big:not(.go) { background: #34332c; color: var(--paper); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.rules button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.seg button:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 900px) {
  /* one swipeable row of levels */
  #levels { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; margin: 12px -12px 0; padding: 0 12px 4px; scrollbar-width: none; }
  #levels::-webkit-scrollbar { display: none; }
  /* the row fades at the edge, so it reads as one you can swipe */
  #levels { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
  #levels.at-end { -webkit-mask-image: none; mask-image: none; }
  #levels button { flex: none; scroll-snap-align: start; padding: 9px 14px; font-size: 14px; }
  .layout { grid-template-columns: 1fr; grid-template-areas: "stage" "panel" "under"; gap: 12px; margin-top: 12px; }
  .layout > .thinkrow { display: none; }
  .layout > .under { margin-top: 0; }
  .layout > .under { grid-template-columns: 1fr; gap: 10px; }
  /* the board stays in view while the controls scroll under it */
  .stage { position: sticky; top: 0; z-index: 5; border-radius: 18px; box-shadow: 0 10px 24px rgba(29,28,23,.10); } /* taste-skill-ignore: sticky bar */
  #board { flex: none; height: clamp(260px, 40svh, 400px); min-height: 0; }
  .genbadge { left: 12px; bottom: calc(8px + var(--below, 0px)); font-size: 13px; }
  .genbadge b { font-size: 1.2rem; }
  .hint { bottom: 8px; left: auto; right: 12px; transform: none; font-size: 12px; }
  #tracker { right: 8px; top: 8px; padding: 6px 10px; gap: 2px 8px; }
  #tracker b { font-size: 1.15rem; }
  #tracker .segs span { width: 10px; height: 8px; }
  /* phones: the narration gets its own line under the board, so it never covers it */
  #say { position: relative; left: auto; right: auto; bottom: auto; width: auto; max-width: none; margin: 6px 8px 8px; min-height: 3.4em;
    display: flex; align-items: center; justify-content: center; border-radius: 14px; transform: none; font-size: 13px; padding: 7px 12px; }
  #say.in { transform: none; }
  #brief, #result > div { max-width: 92%; padding: 18px; gap: 8px; }
  #brief h3, #result h3 { font-size: 1.3rem; }
  #brief p, #result p { font-size: 14px; }
  #brief small { display: none; }
  .go { padding: 12px 22px; }
  /* thinking opens as a bottom sheet */
  #think { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; z-index: 20; max-height: 46svh; overflow: auto; box-shadow: 0 -10px 30px rgba(29,28,23,.25); } /* taste-skill-ignore: bottom sheet */
  /* compact controls */
  .panel { gap: 10px; }
  .block { padding: 14px; border-radius: 18px; }
  .block h2 { font-size: 1rem; margin-bottom: 8px; }
  .rules { gap: 8px; }
  .rules button { min-height: 56px; padding: 12px; font-size: 15px; }
  .rules button span { display: none; }
  .dialrow { grid-template-columns: 88px 1fr; gap: 12px; }
  #knob { width: 88px; height: 88px; }
  #knob::before { inset: 10px; }
  #knob::after { top: 16px; height: 20px; transform-origin: 3px 28px; }
  .dialval { font-size: 1.8rem; }
  .seg button { padding: 12px 4px; }
  .big { padding: 14px; }
  #xray, .speed button { min-height: 44px; }
  #gauge { height: 108px; }
  .gaugeno { font-size: 1.7rem; margin-top: 8px; }
  .gaugesay { font-size: 13px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* short laptop screens: a compact control column, so the board beside it stays near screen height */
@media (min-width: 901px) and (max-height: 820px) {
  .panel { gap: 12px; }
  .layout .block { padding: 14px 16px; }
  .block h2 { margin-bottom: 8px; }
  .rules { gap: 8px; }
  .rules button { padding: 10px 12px; min-height: 0; }
  .rules button span { font-size: 12px; margin-top: 3px; }
  .dialrow { grid-template-columns: 88px 1fr; gap: 12px; }
  #knob { width: 88px; height: 88px; }
  #knob::before { inset: 10px; }
  #knob::after { top: 16px; height: 20px; transform-origin: 3px 28px; }
  .dialval { font-size: 1.8rem; }
  #gauge { height: 110px; }
  .gaugeno { font-size: 1.8rem; margin-top: 8px; }
  .lines { margin-top: 10px; padding-top: 10px; }
}
