:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: #f5f6f8;
  color: #111827;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: #111827;
  color: #f9fafb;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

header h1 {
  font-size: 1rem;
  margin: 0;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-stats {
  color: rgba(249, 250, 251, 0.85);
  font-size: 0.9rem;
  white-space: nowrap;
}

header button {
  background: transparent;
  border: 1px solid rgba(249, 250, 251, 0.6);
  color: #f9fafb;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem 3rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
  width: min(900px, 100%);
  padding: 2rem;
}

h2 {
  margin-top: 0;
  font-size: 1.5rem;
}

form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  box-sizing: border-box;
}

input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: 2px solid #2563eb33;
  border-color: #2563eb;
}

button.primary {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
}

.stack { display: grid; gap: 1.4rem; }
.stack-sm { display: grid; gap: 0.8rem; }

.readonly-box {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e7eb;
  white-space: pre-line;
}

.rich-text {
  white-space: pre-line;
  margin: 0;
}

.matrix { width: 100%; border-collapse: collapse; min-width: 520px; }
.matrix th, .matrix td {
  border: 1px solid #e5e7eb;
  padding: 0.55rem;
  text-align: center;
}
.matrix th { background: #f9fafb; font-size: 0.95rem; }
.matrix td:first-child { font-weight: 600; text-align: left; }

.matrix-wrapper {
  width: 100%;
  overflow-x: auto;
}

.vertical-heading {
  display: inline;
}

.notice {
  padding: 0.75rem;
  border-radius: 8px;
  background: #e0f2fe;
  color: #0c4a6e;
  font-size: 0.95rem;
}

.error {
  padding: 0.75rem;
  border-radius: 8px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.95rem;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-nav-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f9fafb;
}

.admin-nav button {
  background: transparent;
  border: 1px solid rgba(249, 250, 251, 0.6);
  border-radius: 999px;
  color: #f9fafb;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.admin-nav button:hover,
.admin-nav button:focus {
  background: rgba(249, 250, 251, 0.2);
  outline: none;
}

.admin-nav button.active {
  background: #f9fafb;
  color: #111827;
}

.admin-texts {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: grid;
  gap: 1.25rem;
}

.admin-texts-header {
  display: grid;
  gap: 0.5rem;
}

.admin-texts-header label {
  font-weight: 600;
}

.admin-texts-header input[type="search"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
}

.admin-text-table-wrapper {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.admin-text-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-text-table th,
.admin-text-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 0.95rem;
  vertical-align: top;
}

.admin-text-table thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
}

.admin-text-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.admin-text-table tbody tr:hover {
  background: #f3f4f6;
}

.admin-text-table tbody tr.selected {
  background: #dbeafe;
}

.admin-text-table td:last-child {
  white-space: pre-wrap;
}

.admin-text-table tr.empty td {
  text-align: center;
  color: #6b7280;
}

.admin-text-form {
  display: grid;
  gap: 0.75rem;
}

.admin-text-form h3 {
  margin: 0;
  font-size: 1.1rem;
}

.admin-text-form textarea {
  width: 100%;
  min-height: 160px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 0.7rem;
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
}

.admin-text-form button {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.choices.focus-disabled,
.choice-overlay.focus-disabled {
  opacity: 0.25;
  pointer-events: none;
}

.phase-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.stage-frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 40;
}

.focus-cross {
  width: clamp(120px, 28%, 220px);
  aspect-ratio: 1 / 1;
  position: relative;
}
.focus-cross::before,
.focus-cross::after {
  content: '';
  position: absolute;
  background: #f9fafb;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.focus-cross::before { width: 4px; height: 70%; }
.focus-cross::after { height: 4px; width: 70%; }

.stage-frame img {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000;
}

.choice-overlay {
  position: fixed;
  left: 50%;
  bottom: 2.5rem;
  transform: translateX(-50%);
  width: min(90vw, 760px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  z-index: 60;
}

.choices button,
.choice-overlay button {
  font-size: 1.05rem;
  padding: 0.95rem 1.25rem;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: rgba(243, 244, 246, 0.9);
  color: #111827;
  transition: background 0.2s, transform 0.2s;
  backdrop-filter: blur(6px);
}

.choices button:hover,
.choices button:focus,
.choice-overlay button:hover,
.choice-overlay button:focus {
  background: rgba(219, 234, 254, 0.9);
  transform: translateY(-1px);
  outline: none;
}

.phase-meta {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(243, 244, 246, 0.9);
  color: #111827;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-size: 0.95rem;
  z-index: 60;
  backdrop-filter: blur(6px);
  margin: 0;
}

.phase-actions {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 60;
  background: rgba(243, 244, 246, 0.9);
  color: #111827;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(17, 24, 39, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  backdrop-filter: blur(6px);
}

.phase-actions::before {
  content: '×';
  line-height: 1;
}

.phase-stage.mode-focus .choice-overlay {
  display: none;
}

.progress {
  font-size: 0.95rem;
  color: #4b5563;
  text-align: center;
}

.footer-msg {
  text-align: center;
  font-size: 1rem;
  color: #374151;
}

@media (max-width: 600px) {
  html, body { height: 100%; background: #f5f6f8; }
  body { color: #111827; }
  header { flex-direction: column; gap: 0.5rem; align-items: stretch; }
  header h1 { margin-bottom: 0; }
  .header-actions { margin-left: 0; width: 100%; flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .admin-stats { align-self: flex-start; white-space: normal; }
  .admin-nav { width: 100%; margin: 0; }
  header button { width: 100%; }
  main { padding: 0.75rem; flex: 1; }
  .card { padding: 1rem; border-radius: 12px; box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12); width: 100%; min-height: auto; background: #fff; }
  .phase-stage { width: 100vw; height: 100vh; }
  .stage-frame { width: 100vw; height: 100vh; }
  .phase-meta { top: 1rem; background: rgba(17, 24, 39, 0.12); color: #111827; backdrop-filter: none; }
  .choice-overlay { width: calc(100% - 2rem); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; bottom: 2rem; }
  .choice-overlay button { padding: 1rem 0.75rem; background: rgba(243, 244, 246, 0.95); color: #111827; }
  .phase-stage.mode-focus .choice-overlay { display: none; }
  .choices.desktop-only { display: none; }

  .matrix { font-size: 0.9rem; color: #111827; }
  .matrix th, .matrix td { padding: 0.5rem 0.35rem; }
  .matrix thead { position: sticky; top: 0; background: #f9fafb; color: #111827; }
  .matrix thead th .vertical-heading {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    display: inline-block;
    padding: 0.35rem 0.2rem;
  }
  .matrix-wrapper { overflow-x: auto; }
}
