:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #9ca3af;
  --accent: #2563eb;
  --good: #16a34a;
  --bad: #dc2626;
  --soft-good: #dcfce7;
  --soft-bad: #fee2e2;
  --layout-width: 964px;
  --board-width: 616px;
  --work-area-height: 680px;
  --app-height: 712px;
  --app-scale: 1;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

.app {
  position: fixed;
  top: 0;
  left: 50%;
  width: var(--app-width);
  height: var(--app-height);
  margin: 0;
  padding: 16px;
  transform: translateX(-50%) scale(var(--app-scale));
  transform-origin: top center;
}

.screen-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: none;
  padding: 10px 20px;
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  color: #78350f;
  font-weight: 750;
  text-align: center;
}

.screen-warning.visible {
  display: block;
}

#tab-shape header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

#tab-shape .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#tab-shape select,
#tab-shape button {
  height: 38px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

#tab-shape button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 650;
}

#tab-shape button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: #d1d5db;
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-weight: 650;
}

.status strong {
  color: var(--ink);
}

.status strong.is-low {
  color: #dc2626;
}

.shape-work-area main {
  display: grid;
  grid-template-columns: var(--board-width) 1fr;
  gap: 12px;
  align-items: start;
  width: min(100%, var(--layout-width));
  max-width: 100%;
  margin: 0 auto;
}

.shape-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 12px;
  padding: 14px 18px;
  border-radius: var(--hub-radius-md, 12px);
  box-shadow: var(--hub-shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.05));
}

.shape-toolbar .instructions {
  flex: 0 1 auto;
  min-width: 120px;
  border: 1px solid var(--hub-border, #e5e7eb);
  border-radius: 8px;
  background: var(--hub-surface-muted, #f9fafb);
  font-size: 12px;
}

.shape-toolbar .instructions summary {
  cursor: pointer;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.shape-toolbar .instructions-content {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  max-width: 280px;
}

.shape-toolbar .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  justify-content: center;
}

.shape-toolbar .controls button {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 650;
  border-radius: 8px;
  width: auto;
}

.shape-toolbar .status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.shape-toolbar .status span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--hub-surface-muted, #f9fafb);
  border: 1px solid var(--hub-border, #e5e7eb);
}

.shape-toolbar .status strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.panel {
  background: var(--panel);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.board-panel {
  width: var(--board-width);
}

.answers-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.panel-title {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 750;
  color: #374151;
}

.shape-board {
  position: relative;
  width: var(--board-width);
  height: var(--work-area-height);
  background: #fff;
}

.shape {
  position: absolute;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  color: var(--shape-label, var(--ink));
  font-size: 15px;
  font-weight: 500;
  user-select: none;
}

.shape svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.shape text,
.code {
  position: relative;
  z-index: 1;
  font-weight: 500;
  line-height: 1;
}

.shape-triangle .code {
  transform: translateY(18%);
}

.answers {
  height: var(--work-area-height);
  overflow: hidden;
  padding: 0 4px;
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  grid-template-rows: repeat(13, 1fr);
  gap: 4px 4px;
  align-content: start;
}

.answer-row {
  display: flex;
  justify-content: center;
  gap: 3px;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.answer-target {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-weight: 500;
  color: var(--shape-label, var(--ink));
  background: transparent;
  user-select: none;
}

.answer-target svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.answer-target .code {
  font-size: 11px;
}

.answer-row input {
  width: 28px;
  height: 28px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  text-align: center;
  text-transform: uppercase;
  font: 800 15px/1 Inter, ui-sans-serif, system-ui;
  outline: none;
  background: #fff;
}

.answer-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.answer-row input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

.answer-row.correct {
  background: var(--soft-good);
  border-color: rgba(22, 163, 74, 0.35);
}

.answer-row.correct input {
  border-color: var(--good);
}

.answer-row.incorrect {
  background: var(--soft-bad);
  border-color: rgba(220, 38, 38, 0.35);
}

.answer-row.incorrect input {
  border-color: var(--bad);
}

.correct-answer {
  min-width: 12px;
  color: var(--good);
  font-size: 12px;
  font-weight: 750;
  visibility: hidden;
}

.answer-row.incorrect .correct-answer {
  visibility: visible;
}
