/* Supergraphics, the soft 1970s kind: paper, ink and a hue run of flat colours,
   rounded display type, and no sharp corner anywhere. The colour variables
   and the stripe run are set from the table's theme by main.js. */
:root {
  --paper: #efe0c2; --ink: #3b1f12; --accent: #e36a1f; --second: #e8b31e; --third: #8c352b;
  --stripes: linear-gradient(#e8b31e 0 20%, #e9911c 20% 40%, #e36a1f 40% 60%, #c9482a 60% 80%, #8c352b 80% 100%);
  --rule: 3px; --r: 16px; --pill: 999px;
  --display: "Righteous", "Fredoka", "Helvetica Neue", Arial, sans-serif;
  --font: "Fredoka", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--font); font-weight: 500; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
[hidden] { display: none !important; }

/* Header: the wordmark is a ribbon loop and the name in display type */
.bar { display: flex; align-items: center; gap: 12px; height: 66px; padding: 0 14px; flex: none; }
.stripes { height: 10px; flex: none; background: var(--stripes); }
.brand { display: flex; align-items: flex-end; gap: 10px; height: 46px; color: var(--ink); text-decoration: none; }
.brand .loop { height: 42px; width: auto; }
.brand .word { font: 400 26px/0.9 var(--display); letter-spacing: 0.01em; text-transform: uppercase; }
.brand .word em { display: block; font-style: normal; font-size: 13px; letter-spacing: 0.28em; color: var(--accent); margin-top: 2px; }
.name { flex: 1; min-width: 60px; height: 44px; border: var(--rule) solid var(--ink); border-radius: var(--pill); background: transparent; color: var(--ink); font: 400 19px/1 var(--display); padding: 0 18px; text-transform: uppercase; letter-spacing: 0.04em; outline: none; }
.name:focus { background: var(--second); }
.modes, .actions { display: flex; gap: 6px; }
.modes { padding: 3px; border-radius: var(--pill); background: var(--ink); }
.modes button { height: 38px; border: 0; border-radius: var(--pill); background: transparent; color: var(--paper); font: 400 14px/1 var(--display); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 18px; cursor: pointer; }
.modes button.on { background: var(--accent); color: var(--paper); }
.actions button { height: 44px; border: var(--rule) solid var(--ink); border-radius: var(--pill); background: transparent; color: var(--ink); font: 600 13px/1 var(--font); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 16px; cursor: pointer; }
.actions button:hover { background: var(--second); }
.actions button:active { background: var(--ink); color: var(--paper); }

/* Layout */
main { flex: 1; display: grid; grid-template-columns: 158px 1fr 282px; gap: 10px; padding: 10px; min-height: 0; }
main.play { grid-template-columns: 1fr; }
main.play #palette, main.play #props { display: none; }
.panel { overflow: auto; background: var(--paper); border: var(--rule) solid var(--ink); border-radius: var(--r); }
#palette { display: flex; flex-direction: column; gap: 6px; padding: 10px; }
#props { padding: 0 0 24px; }
#stage { position: relative; min-width: 0; min-height: 0; background: var(--ink); border-radius: var(--r); overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

/* Palette: each tool wears one colour of the run */
.panel h2 { margin: 0; padding: 8px 12px 4px; font: 400 11px/1 var(--display); text-transform: uppercase; letter-spacing: 0.2em; color: var(--ink); opacity: 0.7; }
#props h2 { padding: 14px 14px 6px; opacity: 1; font-size: 12px; }
.tool { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 10px 12px 10px 14px; border: 2px solid var(--ink); border-radius: var(--pill); background: transparent; color: var(--ink); font: 600 12.5px/1.05 var(--font); text-transform: uppercase; letter-spacing: 0.03em; text-align: left; cursor: pointer; position: relative; }
.tool::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--accent)); flex: none; margin-right: 8px; }
.tool span { flex: 1; }
.tool:hover { background: var(--second); }
.tool.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tool kbd { font: 600 10px/1 var(--font); padding: 3px 6px; border: 2px solid currentColor; border-radius: var(--pill); opacity: 0.8; }
.hint { position: absolute; left: 12px; right: 12px; bottom: 10px; margin: 0; padding: 7px 14px; border-radius: var(--pill); font-size: 12.5px; font-weight: 600; color: var(--paper); background: rgba(0,0,0,0.55); pointer-events: none; }
main.play .hint { display: none; }

/* Properties */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 8px 14px 12px; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.fields label.check { flex-direction: row; align-items: center; grid-column: 1 / -1; text-transform: none; letter-spacing: 0; font-size: 12px; }
.fields label.wide { grid-column: 1 / -1; }
.fields input, .fields select { width: 100%; padding: 7px 10px; border: 2px solid var(--ink); border-radius: var(--pill); background: rgba(255,255,255,0.55); color: var(--ink); font: 600 14px/1 var(--font); }
.fields input:focus, .fields select:focus { outline: 3px solid var(--accent); outline-offset: -3px; }
.fields input[type=checkbox] { width: 18px; height: 18px; margin: 0 8px 0 0; accent-color: var(--accent); }
.note { margin: 4px 14px 8px; font-size: 12.5px; line-height: 1.35; }
.ok { margin: 8px 14px; padding: 8px 12px; border-radius: var(--pill); background: var(--second); color: var(--ink); font: 400 12px/1.2 var(--display); text-transform: uppercase; letter-spacing: 0.08em; }
.issues { margin: 8px 14px; padding: 8px 12px 8px 26px; border-radius: var(--r); background: var(--accent); color: var(--paper); font-weight: 600; font-size: 12.5px; line-height: 1.4; }
.row { display: flex; gap: 8px; padding: 6px 14px 12px; }
.row button { flex: 1; padding: 10px; border: 2px solid var(--ink); border-radius: var(--pill); background: transparent; color: var(--ink); font: 600 12px/1 var(--font); text-transform: uppercase; cursor: pointer; }
.row button:hover { background: var(--second); }
.row button.danger { background: var(--ink); color: var(--paper); }
.row button.danger:hover { background: var(--accent); }
.bom { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: 12.5px; }
.bom td { padding: 5px 14px; border-bottom: 1px solid rgba(0,0,0,0.12); vertical-align: top; }
.bom td:first-child { width: 54px; text-align: right; font-weight: 700; white-space: nowrap; }
.bom small { display: block; opacity: 0.7; }

/* Backglass: the score panel across the top of the cabinet in play mode */
#hud { position: absolute; top: 0; left: 0; right: 0; height: 86px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 10px 22px; background: var(--paper); border-bottom: 8px solid; border-image: var(--stripes) 1; pointer-events: none; }
#hud .bg-name { font: 400 clamp(16px, 2.6vw, 30px)/1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); }
#hud .bg-score { display: flex; flex-direction: column; align-items: center; line-height: 1; }
#hud .bg-label { font: 400 10px/1 var(--display); letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
#hud #score { font: 400 clamp(32px, 5vw, 54px)/1 var(--display); letter-spacing: 0.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
#hud .bg-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; text-align: right; }
#hud .bg-right span { font: 600 12px/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink); }
#hud .bg-right #status { color: var(--paper); background: var(--ink); padding: 5px 10px; border-radius: var(--pill); }
#hud .bg-right #status:empty { display: none; }
.keys { position: absolute; left: 16px; bottom: 10px; margin: 0; font-size: 11.5px; font-weight: 600; color: var(--paper); opacity: 0.6; pointer-events: none; display: none; }
main.play .keys { display: block; }
@media (pointer: coarse) { .keys { display: none !important; } main.play #stage { padding-bottom: 86px; } }
#touch { position: absolute; left: 0; right: 0; bottom: 0; display: none; grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 8px; }
#touch button { height: 70px; border: 0; border-radius: var(--pill); background: rgba(255,255,255,0.18); color: var(--paper); font: 400 26px/1 var(--display); letter-spacing: 0.05em; touch-action: none; user-select: none; -webkit-user-select: none; }
#touch button:active { background: var(--accent); }
#touch .launch { width: 120px; background: var(--second); color: var(--ink); font-size: 18px; }
@media (pointer: coarse) { #touch:not([hidden]) { display: grid; } }
#toast { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); max-width: 90%; padding: 10px 18px; border-radius: var(--pill); background: var(--second); color: var(--ink); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; pointer-events: none; }

/* Phone */
@media (max-width: 760px) {
  .bar { height: 56px; gap: 6px; padding: 0 8px; }
  .brand { height: 38px; } .brand .loop { height: 32px; } .brand .word { font-size: 18px; } .brand .word em { display: none; }
  .name { height: 38px; font-size: 14px; padding: 0 12px; }
  .modes button { height: 32px; padding: 0 12px; font-size: 12px; }
  .actions button { height: 38px; padding: 0 12px; font-size: 12px; }
  .actions button:nth-child(n+3) { display: none; }
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; gap: 8px; padding: 8px; }
  #palette { grid-row: 1; flex-direction: row; overflow-x: auto; padding: 6px; }
  #palette h2 { display: none; }
  .tool { width: auto; white-space: nowrap; padding: 10px 12px; }
  .tool kbd { display: none; }
  #stage { grid-row: 2; }
  #props { grid-row: 3; max-height: 34dvh; }
  .fields { grid-template-columns: 1fr 1fr 1fr; }
  #hud { height: 64px; padding: 6px 14px; gap: 10px; }
  #hud .bg-right span { font-size: 10px; }
}
