* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Accessibility: visually hidden but available to screen readers */
.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;
}

/* Accessibility: focus indicators */
*:focus-visible {
  outline: 2px solid #4a90d9;
  outline-offset: 2px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

/* Navigation */
.nav {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 12px 20px;
}

.nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: bold;
  color: #333;
  text-decoration: none;
}

.nav-links a {
  color: #4a90d9;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links a:hover {
  text-decoration: underline;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 1.8rem;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.alert {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
}

/* Hero */
.hero {
  text-align: center;
  padding: 40px 0 32px;
}

.hero h1 {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.hero-sub {
  color: #666;
  font-size: 1rem;
  margin-bottom: 24px;
}

.hero-cta {
  display: inline-block;
  width: auto;
  padding: 12px 32px;
  text-decoration: none;
}

/* Section title */
.section-title {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 20px;
}

/* Steps */
.steps {
  padding: 24px 0;
  border-top: 1px solid #e0e0e0;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #4a90d9;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 8px;
}

.step h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.step p {
  color: #666;
  font-size: 0.9rem;
}

/* Create section */
.create-section {
  padding: 24px 0;
  border-top: 1px solid #e0e0e0;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.faq-item summary {
  padding: 14px 16px;
  font-weight: bold;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::after {
  content: "+";
  font-size: 1.2rem;
  color: #888;
  flex-shrink: 0;
  margin-left: 12px;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-answer {
  padding: 0 16px 14px;
  color: #555;
  font-size: 0.95rem;
}

/* Footer */
.footer {
  border-top: 1px solid #ddd;
  padding: 16px 20px;
  margin-top: 32px;
}

.footer-inner {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: #888;
}

.footer-inner a {
  color: #888;
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-bottom: 4px;
}

.footer-links:last-child {
  margin-bottom: 0;
}

/* Policy pages */
.policy {
  font-size: 0.95rem;
}

.policy-section {
  margin-bottom: 24px;
}

.policy-section h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.policy-section p {
  margin-bottom: 8px;
}

.policy-section ul {
  margin-left: 20px;
  margin-bottom: 8px;
}

.policy-section li {
  margin-bottom: 4px;
}

.policy-date {
  text-align: right;
  color: #888;
  font-size: 0.85rem;
  margin-top: 32px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.form-input:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.2);
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: #4a90d9;
  color: #fff;
  width: 100%;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
  width: 100%;
}

.btn-correct {
  background: #28a745;
  color: #fff;
}

.btn-incorrect {
  background: #6c757d;
  color: #fff;
}

/* Judge buttons */
.judge-buttons {
  display: flex;
  gap: 12px;
}

.judge-buttons form {
  flex: 1;
}

.judge-buttons .btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.1rem;
}

/* Buzzer button */
.buzzer-container {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.buzzer-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: #dc3545;
  color: #fff;
  font-size: 1.5rem;
  font-weight: bold;
  border: 6px solid #a71d2a;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}

.buzzer-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

/* Pressed status */
.pressed-status {
  text-align: center;
  padding: 40px 0;
}

.pressed-message {
  font-size: 2rem;
  color: #28a745;
  font-weight: bold;
}

.pressed-order {
  font-size: 1.2rem;
  margin-top: 8px;
}

/* Results list */
.no-results {
  text-align: center;
  color: #888;
  padding: 20px;
}

.results-list {
  list-style: none;
  padding: 0;
}

.results-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #ddd;
  background: #fff;
}

.results-item:first-child {
  border-radius: 8px 8px 0 0;
}

.results-item:last-child {
  border-bottom: none;
  border-radius: 0 0 8px 8px;
}

.results-item:only-child {
  border-radius: 8px;
}

.results-order {
  font-weight: bold;
  font-size: 1.1rem;
  min-width: 40px;
}

.results-name {
  flex: 1;
  font-size: 1.1rem;
}

.results-time {
  color: #888;
  font-size: 0.85rem;
  font-family: monospace;
}

.results-count {
  text-align: right;
  margin-top: 8px;
  color: #666;
}

/* Admin section */
.admin-section {
  margin-bottom: 24px;
}

.url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.url-row .url-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.url-row .btn {
  flex-shrink: 0;
  width: auto;
}

.url-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

/* Share buttons */
.share-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-share {
  flex: 1;
  text-align: center;
  text-decoration: none;
  padding: 12px 16px;
  font-size: 0.85rem;
  width: auto;
  min-height: 44px;
}

.btn-share--native {
  background: #4a90d9;
  color: #fff;
}

.btn-share--line {
  background: #06c755;
  color: #fff;
}

.btn-share--x {
  background: #000;
  color: #fff;
}

.qr-code {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.qr-code svg {
  width: 300px;
  height: 300px;
}

/* Judge overlay */
.judge-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.judge-overlay--visible {
  opacity: 1;
}

.judge-overlay--correct {
  background: rgba(220, 53, 69, 0.15);
}

.judge-overlay--incorrect {
  background: rgba(37, 99, 235, 0.15);
}

.judge-overlay-symbol {
  width: min(60vw, 60vh);
  height: min(60vw, 60vh);
  position: relative;
}

.judge-overlay-symbol--correct {
  border: min(5vw, 5vh) solid #dc3545;
  border-radius: 50%;
}

.judge-overlay-symbol--incorrect {
  display: flex;
  align-items: center;
  justify-content: center;
}

.judge-overlay-symbol--incorrect::before,
.judge-overlay-symbol--incorrect::after {
  content: "";
  position: absolute;
  width: min(5vw, 5vh);
  height: 100%;
  background: #2563eb;
  border-radius: min(2.5vw, 2.5vh);
}

.judge-overlay-symbol--incorrect::before {
  transform: rotate(45deg);
}

.judge-overlay-symbol--incorrect::after {
  transform: rotate(-45deg);
}

/* ===== Panel Quiz ===== */

/* Mode switch */
.mode-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-label {
  font-weight: bold;
}

.mode-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: bold;
}

.mode-badge--buzzer {
  background: #dc3545;
  color: #fff;
}

.mode-badge--panel {
  background: #4a90d9;
  color: #fff;
}

.btn-mode-switch {
  background: #6c757d;
  color: #fff;
  width: auto;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.reveal-section {
  margin-top: 12px;
}

/* Panel tabs */
.panel-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid #ddd;
}

.panel-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #888;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.panel-tab:hover {
  color: #333;
}

.panel-tab--active {
  color: #4a90d9;
  border-bottom-color: #4a90d9;
}

/* Text input pane */
.panel-text-pane {
  margin: 0 auto;
  max-width: 100%;
}

.panel-text-input {
  width: 100%;
  min-height: 150px;
  padding: 16px;
  font-size: 1.1rem;
  border: 2px solid #ccc;
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}

.panel-text-input:focus {
  border-color: #4a90d9;
}

/* Panel canvas */
.panel-canvas-container {
  text-align: center;
  padding: 16px 0;
}

.panel-canvas-wrapper {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
}

.panel-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.btn-fullscreen-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  line-height: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-fullscreen-icon:hover {
  opacity: 1;
}

.btn-fullscreen-icon img {
  display: block;
}

/* Fullscreen mode */
.panel-canvas-container--fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #f5f5f5;
  padding: 12px;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.panel-canvas-container--fullscreen .panel-canvas-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-canvas-container--fullscreen .panel-canvas {
  aspect-ratio: auto;
  flex: 1;
  min-height: 0;
}

.panel-canvas-container--fullscreen .panel-text-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-canvas-container--fullscreen .panel-text-input {
  flex: 1;
  min-height: 0;
}

.panel-canvas-container--fullscreen .panel-tabs {
  flex-shrink: 0;
}

.panel-canvas-container--fullscreen .panel-toolbar {
  flex-shrink: 0;
}

.panel-canvas-container--fullscreen .panel-submit-btn {
  max-width: none;
  flex-shrink: 0;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-panel-tool {
  background: #e9ecef;
  color: #333;
  padding: 10px 16px;
  font-size: 0.85rem;
  width: auto;
  min-height: 44px;
}

/* Color picker */
.panel-color-picker {
  display: flex;
  gap: 6px;
}

.panel-color-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.panel-color-swatch--active {
  border-color: #333;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

/* Pen size */
.panel-pen-size {
  display: flex;
  gap: 6px;
}

.btn-pen-size {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-pen-size--active {
  background: #4a90d9;
  color: #fff;
}

.pen-dot {
  display: block;
  border-radius: 50%;
  background: currentColor;
}

/* Submit button */
.panel-submit-btn {
  margin-top: 16px;
  width: 100%;
  max-width: 300px;
  padding: 14px 20px;
  font-size: 1.1rem;
}

/* Submit error */
.panel-submit-error {
  color: #dc3545;
  font-size: 0.9rem;
  text-align: center;
  margin: 8px 0 0;
}

/* Completed state */
.panel-completed {
  text-align: center;
  padding: 40px 0;
}

.panel-completed-message {
  font-size: 2rem;
  color: #4a90d9;
  font-weight: bold;
}

.panel-completed-sub {
  font-size: 1rem;
  color: #666;
  margin-top: 8px;
}

/* Gallery */
.panel-gallery {
  padding: 16px 0;
}

.panel-gallery-heading {
  text-align: center;
  margin-bottom: 16px;
}

.panel-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.panel-gallery-grid--admin {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.panel-gallery-item {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.panel-gallery-content {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.panel-gallery-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.panel-gallery-text {
  padding: 12px;
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1.4;
  color: #333;
  word-break: break-word;
  white-space: pre-wrap;
  text-align: center;
  margin: 0;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
}

.panel-gallery-name {
  padding: 8px;
  font-weight: bold;
  font-size: 0.9rem;
  border-top: 1px solid #eee;
  margin-top: auto;
}

/* Panel status (admin) */
.panel-status-revealed {
  color: #28a745;
  font-weight: bold;
  text-align: center;
  margin-bottom: 12px;
}

.panel-completed-list {
  list-style: none;
  padding: 0;
}

.panel-completed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
  background: #fff;
}

.panel-completed-item:first-child {
  border-radius: 8px 8px 0 0;
}

.panel-completed-item:last-child {
  border-bottom: none;
  border-radius: 0 0 8px 8px;
}

.panel-completed-item:only-child {
  border-radius: 8px;
}

.panel-completed-check {
  color: #28a745;
  font-weight: bold;
}

.panel-completed-name {
  font-size: 1.1rem;
}

/* Panel timer */
.panel-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: #e8f4fd;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 1.1rem;
}

.panel-timer-label {
  font-weight: 600;
  color: #333;
}

.panel-timer-display {
  font-size: 1.8rem;
  font-weight: bold;
  font-family: monospace;
  color: #4a90d9;
  min-width: 3ch;
  text-align: center;
}

.panel-timer-unit {
  color: #666;
}

.panel-timer--warning {
  background: #fff3cd;
}

.panel-timer--warning .panel-timer-display {
  color: #dc3545;
}

.panel-timer--expired {
  background: #f8d7da;
}

.panel-timer--expired .panel-timer-display {
  color: #dc3545;
}

/* Timer setup (admin) */
.timer-setup {
  margin-top: 12px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.timer-setup-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.timer-setup-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.timer-select {
  flex: 1;
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

.btn-timer-start {
  width: auto;
  padding: 8px 20px;
  flex-shrink: 0;
}

/* Error pages */
.error-page {
  text-align: center;
  padding: 60px 20px;
}

.error-code {
  font-size: 6rem;
  font-weight: 700;
  color: #4a90d9;
  line-height: 1;
  margin-bottom: 16px;
}

.error-message {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 32px;
  line-height: 1.6;
}

.error-btn {
  display: inline-block;
  width: auto;
  padding: 12px 32px;
  text-decoration: none;
}
