:root {
  --ink: #142033;
  --muted: #60708a;
  --surface: #ffffff;
  --surface-strong: #f5f7fb;
  --line: #dce4ef;
  --blue: #1769ff;
  --green: #16a66a;
  --red: #e24d5b;
  --amber: #ffbd3d;
  --teal: #00a4b8;
  --shadow: 0 18px 60px rgba(24, 38, 65, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(23, 105, 255, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(22, 166, 106, 0.16), transparent 30%),
    #eef3f8;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.auth-view {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 440px);
  gap: 24px;
  max-width: 1180px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  align-items: stretch;
}

.brand-panel,
.login-panel,
.control-panel,
.play-panel,
.history-panel,
.instructions-modal {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  min-height: 620px;
  padding: 48px;
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(20, 32, 51, 0.92), rgba(16, 93, 128, 0.78)),
    radial-gradient(circle at 76% 24%, rgba(255, 189, 61, 0.7), transparent 24%),
    #152033;
  color: #fff;
}

.brand-mark,
.mini-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), #ff6b4a);
  color: #10223f;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-panel h1 {
  margin: 8px 0 0;
  font-size: clamp(3rem, 7vw, 6.4rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-copy {
  width: min(560px, 100%);
  margin: 24px 0;
  color: rgba(255, 255, 255, 0.83);
  font-size: 1.14rem;
  line-height: 1.6;
}

.visual-system {
  position: relative;
  min-height: 270px;
}

.orbit {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.orbit-a {
  right: 14%;
  bottom: 8%;
  width: 260px;
  height: 260px;
}

.orbit-b {
  right: 3%;
  bottom: 24%;
  width: 160px;
  height: 160px;
  border-color: rgba(255, 189, 61, 0.55);
}

.core-card {
  position: absolute;
  right: 11%;
  bottom: 20%;
  display: grid;
  gap: 8px;
  width: 190px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
}

.core-card strong {
  font-size: 3.5rem;
  line-height: 1;
}

.core-label,
.core-card span:last-child {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  font-weight: 700;
}

.login-panel {
  align-self: center;
  display: grid;
  gap: 18px;
  padding: 32px;
  border-radius: 8px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 8px 20px rgba(24, 38, 65, 0.12);
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.login-panel label,
.control-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.12);
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  resize: vertical;
  outline: none;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.12);
}

.primary-action,
.secondary-action,
.ghost-action,
.danger-action,
.icon-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
}

.primary-action:hover {
  background: #0f55d8;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-action.ready-action {
  border-color: rgba(22, 166, 106, 0.5);
  background: rgba(22, 166, 106, 0.12);
  color: var(--green);
}

.ghost-action {
  padding: 0 14px;
  background: rgba(23, 105, 255, 0.1);
  color: var(--blue);
}

.danger-action {
  padding: 0 14px;
  background: rgba(226, 77, 91, 0.11);
  color: var(--red);
}

.compact {
  min-width: 148px;
}

.form-note {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.game-view {
  max-width: 1400px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0 22px;
}

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

.mini-mark {
  width: 46px;
  height: 46px;
  font-size: 0.9rem;
}

.topbar-brand div:last-child {
  display: grid;
}

.topbar-brand span {
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr)) auto auto;
  gap: 10px;
  align-items: stretch;
}

.event-chip {
  display: grid;
  min-height: 64px;
  min-width: 168px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background:
    linear-gradient(135deg, rgba(23, 105, 255, 0.08), rgba(0, 164, 184, 0.08)),
    var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 24px rgba(24, 38, 65, 0.08);
}

.event-chip:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.event-chip span,
.event-chip small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.event-chip strong {
  margin: 3px 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
}

.dashboard {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.control-panel,
.play-panel,
.history-panel {
  border-radius: 8px;
}

.control-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.score-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ink), #1a6773);
  color: #fff;
}

.score-card span,
.score-card small,
.metric-grid span,
.stats-list span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-card span,
.score-card small {
  color: rgba(255, 255, 255, 0.72);
}

.score-card strong {
  font-size: 2.7rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-grid,
.stats-list {
  display: grid;
  gap: 10px;
}

.metric-grid {
  grid-template-columns: 1fr 1fr;
}

.metric-grid div,
.stats-list div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.metric-grid strong,
.stats-list strong {
  font-size: 1.3rem;
}

.play-panel {
  min-height: calc(100vh - 130px);
  padding: 24px;
}

.question-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.question-toolbar span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(0, 164, 184, 0.12);
  color: #057988;
  font-size: 0.82rem;
  font-weight: 800;
}

.question-toolbar span:last-child {
  background: rgba(255, 189, 61, 0.18);
  color: #8d5e00;
}

.question-visual {
  height: 150px;
  margin-bottom: 22px;
  border-radius: 8px;
  background: #101b36;
  overflow: hidden;
}

.question-visual canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.question-text {
  min-height: 96px;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 800;
  line-height: 1.25;
}

.question-context {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: rgba(255, 189, 61, 0.14);
  color: #725116;
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.45;
}

.answer-zone {
  display: grid;
  gap: 12px;
  min-height: 170px;
}

.option-button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.option-button:hover,
.option-button.selected {
  border-color: var(--blue);
  background: rgba(23, 105, 255, 0.1);
}

.completion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.feedback-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
}

.answer-actions {
  display: grid;
  gap: 10px;
  min-width: 170px;
}

#feedbackText {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

#feedbackText.correct {
  color: var(--green);
}

#feedbackText.wrong {
  color: var(--red);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.history-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.compact-heading h2 {
  font-size: 1.45rem;
}

.recent-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.recent-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.recent-list li.coach-note {
  border-color: rgba(255, 189, 61, 0.5);
  background: rgba(255, 189, 61, 0.14);
  color: #725116;
  font-weight: 800;
}

.events-view {
  max-width: 1180px;
  margin: 0 auto;
}

.events-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.events-header h2 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.events-header p:last-child {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.event-card {
  min-height: 230px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(24, 38, 65, 0.1);
}

.event-card span {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.event-card h3 {
  margin: 10px 0;
  font-size: 1.22rem;
}

.event-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.55;
}

.event-card a {
  display: inline-flex;
  margin-top: 14px;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.instructions-modal {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

.instructions-modal::backdrop {
  background: rgba(10, 18, 30, 0.48);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.icon-action {
  width: 40px;
  min-height: 40px;
  background: var(--surface-strong);
  color: var(--ink);
}

.instructions-modal ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 20px 28px 24px 40px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

@media (max-width: 1080px) {
  .dashboard {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .history-panel {
    grid-column: 1 / -1;
    grid-template-columns: 220px 1fr;
  }

  .recent-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 14px;
  }

  .auth-view,
  .dashboard,
  .events-grid,
  .history-panel {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 470px;
    padding: 28px;
  }

  .login-panel {
    align-self: stretch;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .control-panel {
    position: static;
  }

  .play-panel {
    min-height: auto;
  }

  .recent-list {
    grid-template-columns: 1fr;
  }

  .feedback-row {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-actions {
    width: 100%;
  }

  .events-header {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .brand-panel h1 {
    font-size: 3rem;
  }

  .visual-system {
    min-height: 190px;
  }

  .orbit-a {
    right: -20%;
    width: 220px;
    height: 220px;
  }

  .core-card {
    right: 8%;
    width: 165px;
  }

  .topbar-actions,
  .topbar-actions button {
    width: 100%;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }
}

.profile-link {
  width: fit-content;
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 0.88rem;
  font-weight: 800;
}

.profile-link:hover {
  color: var(--blue);
}

.start-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  width: min(560px, 100%);
  min-height: 0;
  gap: 14px;
  margin: 34px auto 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 105, 255, 0.08), rgba(22, 166, 106, 0.08)),
    var(--surface-strong);
  text-align: center;
  box-shadow: 0 18px 48px rgba(24, 38, 65, 0.12);
}

.start-panel h2 {
  margin: 4px 0 8px;
  font-size: clamp(1.35rem, 2.3vw, 1.9rem);
  line-height: 1;
}

.start-panel p {
  max-width: 500px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.42;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.question-area {
  display: block;
}

.feedback-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.answer-explain {
  max-width: 780px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-strong);
}

.answer-explain summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 800;
}

.answer-explain p {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.answer-explain ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.answer-explain a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.events-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto;
  gap: 12px;
  align-items: end;
}

.events-controls label,
.profile-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.profile-modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.profile-modal::backdrop {
  background: rgba(10, 18, 30, 0.48);
}

.profile-form {
  background: var(--surface);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

.profile-grid label:last-child {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 20px 20px;
}

@media (max-width: 820px) {
  .events-controls,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .start-panel {
    width: 100%;
  }
}
