:root {
  --bg: #c72c16;
  --bg-dark: #a92313;
  --panel: #d83b1f;
  --white: #fff7ed;
  --text: #fffdf8;
  --muted: #ffd7c5;
  --gold: #ffc400;
  --teal: #009b9e;
  --olive: #97a62a;
  --ink: #2b120c;
  --red: #bf1d12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button, select, input {
  font: inherit;
}

button {
  border: 0;
  min-height: 40px;
  border-radius: 20px;
  padding: 0 15px;
  color: var(--ink);
  background: var(--white);
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--white);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--gold);
}

button.active, .primary {
  background: var(--gold);
}

button.danger {
  background: var(--bg-dark);
  color: var(--white);
}

.icon-btn {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 22px;
  overflow: hidden;
  isolation: isolate;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font: 900 24px/0.92 "Arial Black", Arial, sans-serif;
}

.logo {
  position: relative;
  width: 86px;
  height: 72px;
}

.mini-orbit {
  position: absolute;
  left: 10px;
  top: 27px;
  width: 66px;
  height: 24px;
  border: 4px solid var(--white);
  border-radius: 50%;
}
.mini-orbit.b { transform: rotate(60deg); }
.mini-orbit.c { transform: rotate(120deg); }
.logo .core {
  position: absolute;
  left: 35px;
  top: 31px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--olive);
}

.session {
  color: var(--white);
  font-weight: 900;
  text-align: right;
  white-space: pre-line;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(470px, 1fr) minmax(320px, 370px);
  gap: 16px;
  align-items: stretch;
}

.panel {
  border: 5px solid var(--white);
  background: var(--panel);
  min-height: 720px;
  box-shadow: 0 12px 0 rgba(43, 18, 12, 0.15);
}

.settings, .stats {
  padding: 18px;
}

h2 {
  margin: 0 0 14px;
  font: 900 22px/1 "Arial Black", Arial, sans-serif;
}

.section {
  margin-bottom: 14px;
}

label, .inline-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mode-grid button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.stacked {
  display: grid;
  gap: 7px;
}

.inline-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 2px solid rgba(255, 247, 237, 0.28);
}

.inline-row span {
  margin: 0;
}

select, input {
  border: 0;
  border-radius: 18px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--white);
  font-weight: 900;
}

input {
  width: 84px;
  text-align: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.main-actions {
  margin: 14px 0 10px;
}

.trainer {
  padding: 24px 18px 18px;
  text-align: center;
  background: var(--bg);
}

.caption {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.question {
  min-height: 74px;
  margin: 3px 0 0;
  font: 900 clamp(38px, 5vw, 58px)/1.05 "Arial Black", Arial, sans-serif;
}

.timer {
  height: 32px;
  color: var(--gold);
  font: 900 22px/1 "Arial Black", Arial, sans-serif;
}

.answer {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 210px;
  min-height: 62px;
  margin: 8px 0 14px;
  padding: 8px 20px;
  color: var(--text);
  background: var(--bg-dark);
  font: 900 30px/1 "Arial Black", Arial, sans-serif;
}

.pad {
  margin: 0 auto 14px;
}

.hidden { display: none !important; }

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  justify-content: center;
  gap: 8px;
}

.number-pad button, .range-pad button {
  min-height: 44px;
  font: 900 18px/1 "Arial Black", Arial, sans-serif;
}

.blank {
  visibility: hidden;
}

.rank-row, .suit-row, .rank-pad, .suit-pad, .range-pad {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.rank-row {
  max-width: 520px;
  margin: 0 auto 16px;
}

.rank-row button, .rank-pad button {
  width: 62px;
}

.suit-row button, .suit-pad button {
  width: 96px;
  min-height: 58px;
  font-size: 28px;
}

.range-pad {
  max-width: 430px;
}

.range-pad button {
  width: 98px;
}

.red {
  color: var(--red);
}

.trainer-actions {
  justify-content: center;
  margin-top: 12px;
}

.feedback {
  min-height: 28px;
  max-width: 640px;
  margin: 12px auto 0;
  color: var(--white);
  font-size: 15px;
  font-weight: 900;
}

.accuracy {
  font: 900 56px/1 "Arial Black", Arial, sans-serif;
}

.verdict {
  min-height: 42px;
  margin: 4px 0 12px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.stats-scroll {
  max-height: 600px;
  overflow: auto;
  padding-right: 8px;
  font-size: 13px;
  font-weight: 800;
}

.stats-section {
  margin: 0 0 16px;
}

.stats-section h3 {
  margin: 0 0 7px;
  color: var(--gold);
  font: 900 13px/1 "Arial Black", Arial, sans-serif;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 247, 237, 0.22);
}

.stat-line span:first-child {
  color: var(--muted);
}

.stat-line strong {
  color: var(--white);
  text-align: right;
}

.issue {
  margin: 7px 0;
  color: var(--white);
  line-height: 1.25;
}

.app-footer {
  margin: 16px auto 0;
  max-width: 980px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 18, 12, 0.62);
}

.modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 22px;
  border: 5px solid var(--white);
  background: var(--panel);
  box-shadow: 0 18px 0 rgba(43, 18, 12, 0.2);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
}

.modal-panel select,
.modal-panel textarea {
  width: 100%;
  margin: 0 0 14px;
}

textarea {
  border: 0;
  border-radius: 18px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--white);
  font: 800 15px/1.35 Arial, Helvetica, sans-serif;
  resize: vertical;
}

.report-preview {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--bg-dark);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.modal-actions {
  justify-content: flex-start;
}

.feedback-note {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--gold);
  font-weight: 900;
}

.feedback-email {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

@media (max-width: 1120px) {
  .app-shell {
    padding: 14px;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .panel {
    min-height: auto;
  }
  .stats-scroll {
    max-height: none;
  }
}
