/* The web simulator's page (web/README.md). PlayGuard's colours: the teal
   of the focus highlight, on a navy that frames the console's screen. */
/* Light by default; dark when the page says so (data-theme, set before the
   first paint from the URL, the choice kept or the system's). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #17202e;
  --muted: #5b6678;
  --line: #d9dee6;
  --accent: #0a705f;
  --accent-text: #ffffff;
  --frame: #0f1724;
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b111b;
  --surface: #131b28;
  --surface-2: #1a2433;
  --text: #e6ebf2;
  --muted: #8392aa;
  --line: #273245;
  --accent: #22b39a;
  --accent-text: #04140f;
  --frame: #05090f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: inherit; text-decoration: none; }
.brand img { border-radius: 6px; }
.brand .tag {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.build { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build a { color: inherit; }
.build code { font-size: 12px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 0;
}
.layout.no-panel { grid-template-columns: minmax(0, 1fr); }
.layout.no-panel .panel { display: none; }

.stage { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; overflow: auto; }
.screen {
  position: relative;
  width: 100%;
  max-width: calc((100vh - 236px) * 16 / 9);
  min-width: 0;
  margin: 0 auto;
  background: var(--frame);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.18);
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  outline: none;
  touch-action: none;
  background: #000;
}
canvas:focus-visible { box-shadow: 0 0 0 3px var(--accent); }

.overlay {
  position: absolute;
  inset: 10px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--frame);
  color: #c9d3e1;
  text-align: center;
  padding: 24px;
}
.overlay.error .spinner { display: none; }
.overlay p { margin: 0; max-width: 46ch; }
.overlay button { margin-top: 4px; }
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 0.15);
  border-top-color: #22b39a;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  width: 100%;
  max-width: calc((100vh - 236px) * 16 / 9);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.keys { margin: 0; color: var(--muted); font-size: 13px; }
@media (pointer: coarse) { .keys { display: none; } }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}
.control-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#record[aria-pressed="true"] { border-color: #d1495b; color: #d1495b; }
#record[aria-pressed="true"]::before { content: "● "; }

/* The console's time moved on (skip=): a row under the controls. */
.time {
  width: 100%;
  max-width: calc((100vh - 236px) * 16 / 9);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}
.time-label { color: var(--muted); }
.time-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.time .btn { padding: 4px 10px; font-size: 13px; }
.time .btn:disabled { opacity: 0.45; cursor: default; }
.skip-shown { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

.overlay progress { width: min(260px, 70%); accent-color: #22b39a; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 8px;
  background: rgb(15 23 36 / 0.9);
  color: #e6ebf2;
  font-size: 13px;
  pointer-events: none;
}

.pad {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: none;
  -webkit-user-select: none;
}
.pad button {
  touch-action: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  min-width: 48px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}
.pad button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.pad-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.shoulders button.small { min-width: 40px; border-radius: 999px; }
.dpad, .face { display: grid; grid-template: repeat(3, 48px) / repeat(3, 48px); gap: 4px; }
.dpad .up { grid-area: 1 / 2; } .dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; } .dpad .down { grid-area: 3 / 2; }
.face button { border-radius: 50%; }
.face .x { grid-area: 1 / 2; } .face .y { grid-area: 2 / 1; }
.face .a { grid-area: 2 / 3; } .face .b { grid-area: 3 / 2; }

.panel {
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab {
  border: 0;
  background: none;
  padding: 10px 12px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { flex: 1; overflow: auto; padding: 12px 16px; min-height: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; }
.field > span { font-size: 13px; color: var(--muted); }
.field.check { flex-direction: row; align-items: flex-start; gap: 8px; }
.field.check > span { color: var(--text); font-size: 14px; }
.field.check input { margin-top: 3px; accent-color: var(--accent); }
.field.changed > span { color: var(--accent); font-weight: 600; }
.help { margin: -2px 0 10px; font-size: 12px; color: var(--muted); }
.field.check + .help { margin-left: 24px; }
input:not([type="checkbox"]), select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.preset { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.group { border-bottom: 1px solid var(--line); padding: 8px 0; }
.group summary { cursor: pointer; font-weight: 600; padding: 4px 0; list-style-position: inside; }
.group summary .count {
  font-weight: 500;
  font-size: 12px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
}
.group[open] summary { margin-bottom: 8px; }
.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-bottom: 10px; }
.multi .field.check { margin: 0; }
.multi .field.check > span { font-size: 13px; }

.other-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.other-row code { flex: 0 0 auto; font-size: 12px; }
.other-row input { flex: 1; }
.add-other { display: flex; gap: 6px; }

.log {
  margin: 0;
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}
.log .err { color: #d1495b; }

.panel-actions { display: flex; gap: 8px; padding: 12px 16px 6px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.note { margin: 0; padding: 0 16px 12px; font-size: 12px; color: var(--muted); }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary.pending { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: transparent; }
.header-settings { display: flex; gap: 8px; margin-left: auto; }
.header-settings select { width: auto; padding: 5px 8px; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.notice {
  width: 100%;
  max-width: calc((100vh - 236px) * 16 / 9);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }

@media (max-width: 900px) {
  html, body { height: auto; }
  .layout { display: block; }
  .stage { padding: 12px 16px; overflow: visible; }
  .screen, .controls, .time { max-width: none; }
  .screen { padding: 6px; border-radius: 10px; }
  .overlay { inset: 6px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .tab-body { max-height: none; overflow: visible; }
  .build { display: none; }
  .top { flex-wrap: wrap; }
  .notice { max-width: none; }
  .panel-actions { position: sticky; bottom: 0; background: var(--surface); }
}
