:root {
  --ivory: #f3ecdc;
  --ivory-2: #e6dcc6;
  --ink: #241c14;
  --ink-soft: #5d4f3e;
  --walnut: #2a1c13;
  --felt: #6e1f22;
  --brass: #d8a73c;
  --red: #c8321f;
  --amber: #d98b1c;
  --green: #3f7a4a;
  --steel: #7f9bb0;
  --panel-w: 330px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--walnut); color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 16px;
}
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
kbd {
  font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  background: var(--walnut); color: var(--ivory); border-radius: 4px; padding: 1px 6px;
}
[hidden] { display: none !important; }

#hud {
  position: fixed; top: 0; left: 0; right: var(--panel-w);
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; color: var(--ivory);
  background: linear-gradient(to bottom, rgba(20, 13, 8, 0.92), rgba(20, 13, 8, 0.6));
  border-bottom: 1px solid #5a4330;
}
.hud-title { display: flex; flex-direction: column; }
#hud-unit { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
#hud-place { font-size: 14px; color: #cbb89a; font-style: italic; }
.hud-stats { display: flex; gap: 24px; }
.hud-stats div { display: flex; flex-direction: column; align-items: center; }
.hud-stats b { font-size: 20px; font-variant-numeric: tabular-nums; }
.hud-stats small { font-size: 12px; color: #cbb89a; text-transform: uppercase; letter-spacing: 0.08em; }
#hud-clock.late { color: #ff8a6a; }

#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  background: var(--ivory); border-left: 2px solid #8a6a48;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.35);
}
#panel h2 {
  margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-soft); border-bottom: 1px solid #c8b893; padding-bottom: 6px;
}
#inspect { background: var(--ivory-2); border-radius: 6px; padding: 10px 12px; min-height: 178px; }
#inspect-head { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
#inspect-body { font-size: 14px; line-height: 1.45; white-space: pre-line; }
#inspect-body .bad { color: var(--red); font-weight: 700; }
#inspect-body .ok { color: var(--green); font-weight: 700; }
#inspect-body .warn { color: #a5600f; font-weight: 700; }
#turn { font-size: 15px; }
#turn small { color: var(--ink-soft); font-size: 12px; }
#turn-pips { display: flex; gap: 6px; margin-top: 6px; }
#turn-pips span {
  flex: 1; text-align: center; font-size: 13px; padding: 3px 0; border-radius: 4px;
  border: 1px solid #b9a887; color: var(--ink-soft);
}
#turn-pips span.on { background: var(--walnut); color: var(--ivory); border-color: var(--walnut); }
#log {
  flex: 1; margin: 0; padding: 0 0 0 20px; font-size: 14px; line-height: 1.4;
  color: var(--ink-soft); overflow: hidden; font-style: italic;
}
#log li:last-child { color: var(--ink); }
#keys { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--ink-soft); }

#coach {
  position: fixed; left: 50%; transform: translateX(calc(-50% - var(--panel-w) / 2));
  bottom: 22px; max-width: 680px; background: var(--ivory); color: var(--ink);
  padding: 10px 18px 12px; border-radius: 8px; font-size: 17px; line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); border-left: 5px solid var(--brass);
}
#coach-who { font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-soft); }
#refusal {
  position: fixed; left: 50%; transform: translateX(calc(-50% - var(--panel-w) / 2));
  top: 84px; background: rgba(243, 236, 220, 0.96); color: var(--ink);
  padding: 8px 16px; border-radius: 6px; font-size: 15px; opacity: 0;
  transition: opacity 0.2s; pointer-events: none;
}
#refusal.show { opacity: 1; }

.card-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 9, 5, 0.55);
}
.card {
  background: var(--ivory); border: 2px solid #8a6a48; border-radius: 10px;
  padding: 28px 36px; max-width: 740px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-height: 94vh; overflow: auto;
}
.card.small { max-width: 440px; text-align: center; }
.card h1 { margin: 4px 0 10px; font-size: 40px; letter-spacing: 0.06em; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.18em; font-size: 13px; color: var(--ink-soft); }
.pitch, .idea { font-size: 18px; line-height: 1.5; }
.idea { font-style: italic; color: var(--ink-soft); }
.due { font-size: 16px; }
.place { font-style: italic; color: var(--ink-soft); margin-top: -6px; }
#brief-lines { font-size: 17px; line-height: 1.55; padding-left: 20px; }
.controls { border-collapse: collapse; font-size: 15px; margin: 10px 0; }
.controls td { padding: 4px 10px 4px 0; vertical-align: top; }
.controls td:first-child { font-weight: 700; white-space: nowrap; }
.go { margin-top: 16px; font-size: 16px; }
#report-stars { color: var(--amber); font-size: 44px; }
#report-table { border-collapse: collapse; font-size: 16px; margin: 8px 0; }
#report-table td { padding: 3px 18px 3px 0; }
#report-table td:last-child { font-variant-numeric: tabular-nums; font-weight: 700; }

@media (max-width: 899px) {
  :root { --panel-w: 0px; }
  #panel { display: none !important; }
  #hud { padding: 6px 10px; }
  #hud-place, .hud-stats small { display: none; }
  .hud-stats { gap: 12px; }
  .hud-stats b, #hud-unit { font-size: 15px; }
  #coach { bottom: 6px; font-size: 13px; max-width: 86vw; padding: 6px 12px; line-height: 1.3; }
  #coach-who { display: none; }
  .card { padding: 12px 18px; }
  .card h1 { font-size: 24px; margin: 2px 0 4px; }
  .kicker { font-size: 12px; }
  .pitch, .idea, #brief-lines { font-size: 13px; line-height: 1.35; margin: 4px 0; }
  .controls { font-size: 12px; margin: 4px 0; }
  .controls td { padding: 1px 8px 1px 0; }
  .go { margin-top: 6px; font-size: 13px; }
}
