:root {
  --pc-blue: #149bd7;
  --pc-ink: #102131;
  --pc-muted: #5c6b78;
  --pc-paper: #eef4f8;
  --pc-panel: #ffffff;
  --pc-line: #d8e2ea;
  --pc-dark: #071018;
  --pc-green: #1d8f5a;
  --pc-amber: #f3b23a;
  --pc-red: #d84f4f;
  --pc-violet: #6d5fd0;
  --pc-radius: 8px;
  --pc-touch: 48px;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  color: var(--pc-ink);
  background:
    linear-gradient(#dce8f0 1px, transparent 1px),
    linear-gradient(90deg, #dce8f0 1px, transparent 1px),
    var(--pc-paper);
  background-size: 34px 34px;
  touch-action: manipulation;
}

button,
select { font: inherit; }

button {
  min-height: var(--pc-touch);
  border: 2px solid transparent;
  border-radius: var(--pc-radius);
  cursor: pointer;
  user-select: none;
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(20, 155, 215, 0.38);
  outline-offset: 2px;
}

.power-clue-app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: var(--pc-dark);
  color: #ffffff;
}

.brand,
.top-actions,
.toolbar,
.control-group,
.power-clue-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand { min-width: 0; gap: 12px; }
.brand-logo { display: inline-flex; border-radius: 6px; }
.brand h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 2.05rem); line-height: 1.05; font-weight: 800; }
.top-actions { justify-content: end; }

.icon-button {
  width: var(--pc-touch);
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #122436;
  color: #ffffff;
  border-color: #263d51;
}

.icon-button:hover,
.home-button:hover,
.home-button:focus-visible { background: var(--pc-blue); border-color: #8fd8f3; color: #06111a; }

.icon {
  width: 24px;
  height: 24px;
  display: block;
  pointer-events: none;
}

.home-button {
  min-height: var(--pc-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 2px solid #263d51;
  border-radius: var(--pc-radius);
  background: #122436;
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar {
  justify-content: center;
  flex-wrap: wrap;
  padding: 6px 14px;
  border-bottom: 1px solid var(--pc-line);
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(15, 33, 49, 0.06);
  z-index: 3;
}

.control-label {
  color: var(--pc-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.control-group select {
  min-height: var(--pc-touch);
  padding: 0 12px;
  border: 2px solid var(--pc-line);
  border-radius: var(--pc-radius);
  background: #ffffff;
  color: var(--pc-ink);
  font-weight: 800;
}

.wide-button {
  min-height: var(--pc-touch);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--pc-line);
  background: #f8fbfd;
  color: var(--pc-ink);
  font-weight: 900;
  white-space: nowrap;
}

.wide-button.primary { background: var(--pc-violet); border-color: #4d409f; color: #ffffff; }

.power-clue-button {
  min-height: var(--pc-touch);
  padding: 0 14px;
  border-color: var(--pc-line);
  background: #f8fbfd;
  color: var(--pc-ink);
  font-weight: 900;
}

.power-clue-button.is-primary { background: var(--pc-violet); border-color: #4d409f; color: #ffffff; }
.power-clue-button.is-check { background: var(--pc-green); border-color: #126b41; color: #ffffff; }
.power-clue-button.is-support { border-color: #b58a22; background: #fff6da; }
.power-clue-button.is-reveal { border-color: #bd5757; background: #fff0f0; }

.power-clue-shell {
  width: min(1440px, calc(100% - 20px));
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 8px 0;
  overflow: hidden;
}

.power-clue-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.power-clue-board,
.power-clue-side {
  min-height: 0;
  border: 1px solid var(--pc-line);
  border-radius: var(--pc-radius);
  background: var(--pc-panel);
  box-shadow: 0 12px 30px rgba(15, 33, 49, 0.13);
}

.power-clue-board {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 7px;
  padding: 9px;
  overflow: hidden;
}

.power-clue-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--pc-line);
  border-radius: var(--pc-radius);
  overflow: hidden;
  background: #fbfdff;
}

.power-clue-stat {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-right: 1px solid var(--pc-line);
  text-align: center;
}
.power-clue-stat:last-child { border-right: 0; }
.power-clue-stat span { color: var(--pc-muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.power-clue-stat strong { font-size: clamp(1.05rem, 1.8vw, 1.45rem); line-height: 1; }

.power-clue-clues {
  display: grid;
  gap: 5px;
}

.power-clue-clue,
.power-clue-support,
.power-clue-resolution {
  margin: 0;
  padding: 7px 10px;
  border: 2px solid var(--pc-line);
  border-radius: var(--pc-radius);
  background: #f8fbfd;
  text-align: center;
  font-weight: 900;
  line-height: 1.2;
}

.power-clue-clue { font-size: clamp(1rem, 1.6vw, 1.35rem); }
.power-clue-support { border-color: #e1bd5c; background: #fff8df; color: #684c08; }
.power-clue-resolution { border-color: #75b99a; background: #edfaf4; color: #145f3d; }

.power-clue-model {
  min-height: 0;
  display: grid;
  place-items: stretch;
  overflow: hidden;
  border: 2px solid #c8d9e5;
  border-radius: var(--pc-radius);
  background: #ffffff;
}

.power-clue-model .gattegno-interactive,
.power-clue-model .gattegno-model-host,
.power-clue-model .spire-diagram,
.power-clue-model figure {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

.power-clue-model svg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
}

.power-clue-model figcaption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.power-clue-candidate {
  margin: 0;
  color: var(--pc-muted);
  text-align: center;
  font-weight: 800;
}

.power-clue-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.power-clue-side {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}
.power-clue-side h2 { margin: 0; font-size: 1rem; }
.power-clue-side-note { margin: 0; color: var(--pc-muted); font-size: 0.88rem; font-weight: 800; line-height: 1.3; }

.power-clue-scores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.power-clue-team {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 9px;
  border: 2px solid var(--pc-line);
  border-radius: var(--pc-radius);
  background: #ffffff;
}
.power-clue-team.is-active { border-color: var(--pc-violet); background: #f2f0ff; }
.power-clue-team span { color: var(--pc-muted); font-size: 0.72rem; font-weight: 900; text-transform: uppercase; }
.power-clue-team strong { font-size: 1.45rem; line-height: 1; }

@media (max-width: 760px), (max-height: 699px) {
  html,
  body { height: auto; min-height: 100%; overflow: auto; }
  .power-clue-app { height: auto; min-height: 100vh; overflow: visible; }
  .power-clue-shell { width: min(100% - 12px, 760px); overflow: visible; }
  .power-clue-layout { grid-template-columns: 1fr; height: auto; }
  .power-clue-side { grid-row: 1; overflow: visible; }
  .power-clue-board { grid-row: 2; min-height: 720px; overflow: visible; }
  .power-clue-scores { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr; }
  .top-actions { justify-content: start; }
}

@media (max-width: 520px) {
  .brand h1 { font-size: 1.15rem; }
  .toolbar { justify-content: stretch; }
  .control-group { flex: 1 1 100%; justify-content: space-between; }
  .control-group select { flex: 1; }
  .toolbar .wide-button { width: 100%; }
  .power-clue-scores { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .power-clue-actions .power-clue-button { flex: 1 1 42%; }
}

@page { size: A4 landscape; margin: 8mm; }

@media print {
  html,
  body { width: 100%; height: auto; overflow: visible; background: #ffffff; }
  .power-clue-app { display: block; height: auto; overflow: visible; }
  .topbar,
  .toolbar,
  .power-clue-actions { display: none !important; }
  .power-clue-shell { width: 100%; height: auto; padding: 0; overflow: visible; }
  .power-clue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 58mm; height: 174mm; }
  .power-clue-board,
  .power-clue-side { box-shadow: none; break-inside: avoid; }
  .power-clue-board { height: 174mm; }
  .power-clue-model { min-height: 90mm; }
  .power-clue-model svg { max-height: 112mm !important; }
  .spire-print-brand { margin-bottom: 3mm; }
}
