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

:root {
  --bg-start: #ffe6b0;
  --bg-end: #ffb77c;
  --accent-pink: #ff3e6c;
  --accent-orange: #ff8344;
  --panel-bg: #fffaf2e6;
  --soft-yellow: #fff2df;
  --soft-border: #ffcd94;
  --text-brown: #b45f2b;
}

a {
  text-decoration: none;
  color: #d35400;
  font-weight: bold;
  transition: color 0.2s;
}

a:hover {
  color: #e67e22;
}

body {
  min-height: 100vh;
  background: linear-gradient(130deg, var(--bg-start) 0%, var(--bg-end) 100%);
  font-family:
    "Comic Neue", "Chalkboard SE", "Comic Sans MS", "Poppins", "Segoe UI",
    cursive, sans-serif;
  padding: 24px 20px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

body::before {
  content: "🐣 🦊 🐼 🐧 🎈";
  font-size: 48px;
  position: fixed;
  bottom: 10px;
  left: 10px;
  opacity: 0.2;
  pointer-events: none;
  white-space: pre;
  transform: rotate(-5deg);
}

body::after {
  content: "🌟 ✨ ⭐ 💫";
  font-size: 55px;
  position: fixed;
  top: 20px;
  right: 5px;
  opacity: 0.2;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.game-shell,
.teacher-shell,
.leaderboard-shell {
  width: 100%;
  max-width: 1320px;
}

.game-container,
.teacher-panel,
.leaderboard-panel {
  width: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(3px);
  border-radius: 80px;
  box-shadow:
    0 25px 40px rgba(0, 0, 0, 0.25),
    0 0 0 5px #ffedb5,
    0 0 0 12px #ffbc6e;
  padding: 24px 20px 32px;
  transition: 0.2s;
}

.player-banner,
.teacher-topbar,
.leaderboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.88);
  border: 2px solid #ffd69f;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.player-banner-left,
.teacher-topbar-left,
.leaderboard-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rank-avatar,
.teacher-student-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff4dc;
  border: 4px solid #ffcf98;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.player-name,
.teacher-page-title,
.leaderboard-page-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #7f3f11;
}

.player-meta,
.teacher-page-subtitle,
.leaderboard-page-subtitle {
  color: #a86b31;
  font-size: 0.92rem;
  margin-top: 4px;
}

.secondary-btn,
.primary-btn,
.refresh-btn,
.nav-btn,
.export-btn,
.reset-btn,
.victory-btn,
.teacher-action-btn {
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.primary-btn,
.victory-btn,
.teacher-action-btn {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-pink));
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 62, 108, 0.3);
}

.secondary-btn,
.refresh-btn,
.nav-btn,
.export-btn,
.reset-btn {
  background: #ffedd0;
  color: #8a4f1f;
  box-shadow: 0 6px 0 #ecbd7b;
}

.primary-btn:hover,
.secondary-btn:hover,
.refresh-btn:hover,
.nav-btn:hover,
.export-btn:hover,
.reset-btn:hover,
.victory-btn:hover,
.teacher-action-btn:hover {
  transform: translateY(-2px);
}

.primary-btn:active,
.secondary-btn:active,
.refresh-btn:active,
.nav-btn:active,
.export-btn:active,
.reset-btn:active,
.victory-btn:active,
.teacher-action-btn:active {
  transform: translateY(1px);
}

.game-header,
.teacher-header,
.leaderboard-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-header h1,
.teacher-header h1,
.leaderboard-header h1 {
  font-size: 2.6rem;
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-pink));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 4px 4px 0 #ffe0a3;
  letter-spacing: -1px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.stats,
.summary-cards,
.teacher-meta-grid {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  background: var(--soft-yellow);
  border-radius: 40px;
  padding: 10px 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
  border: 2px solid var(--soft-border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.matched-counter,
.summary-card,
.teacher-meta-card {
  background: #ff9f4b;
  color: #2e241d;
  font-weight: 800;
  padding: 12px 18px;
  border-radius: 28px;
  font-size: 1rem;
  box-shadow: 0 5px 0 #b4621a;
}

.stats-text {
  color: #8a5019;
  font-weight: 800;
  padding: 12px 4px;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.summary-card,
.teacher-meta-card {
  flex: 1;
  min-width: 180px;
  background: linear-gradient(135deg, #ffe8bb, #ffd18a);
}

.summary-card .summary-label,
.teacher-meta-card .summary-label {
  display: block;
  font-size: 0.82rem;
  color: #975112;
  margin-bottom: 6px;
}

.summary-card .summary-value,
.teacher-meta-card .summary-value {
  font-size: 1.35rem;
  color: #653308;
}

.remaining-info {
  font-weight: 700;
  color: var(--text-brown);
  background: #fff1e0;
  padding: 6px 18px;
  border-radius: 30px;
  flex: 1;
  min-width: 240px;
}

.reset-btn,
.refresh-btn,
.nav-btn,
.export-btn,
.teacher-action-btn,
.secondary-btn {
  padding: 10px 22px;
  font-size: 0.98rem;
}

.primary-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.08rem;
}

.game-board {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  margin: 20px 0 20px;
}

.column,
.teacher-card,
.leaderboard-card {
  flex: 1;
  min-width: 280px;
  border-radius: 44px;
  padding: 22px 16px;
  transition: all 0.2s;
}

.col-scenario {
  background: #ffe0f0;
  border: 4px solid #ff80ab;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
}

.col-risk {
  background: #fff1b5;
  border: 4px solid #f9a825;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
}

.column h2,
.teacher-card h2,
.leaderboard-card h2 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 20px;
  font-weight: 800;
  display: inline-block;
  width: 100%;
  border-radius: 60px;
  padding: 10px 0;
}

.col-scenario h2 {
  background: #ffcddf;
  color: #b3456f;
  border-bottom: 4px dashed #ff99bb;
}

.col-risk h2 {
  background: #f9cf86;
  color: #a3510c;
  border-bottom: 4px dashed #f6b33d;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.scenario-card,
.risk-card {
  padding: 15px 14px;
  border-radius: 48px;
  cursor: pointer;
  font-weight: bold;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.1);
  border: 2px solid white;
  height: 100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.scenario-card {
  background: #fff1f9;
  color: #982b56;
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  text-align: left;
  line-height: 1.4;
  border-left: 12px solid #ff99bb;
  align-items: flex-start;
  padding-left: 20px;
  padding-right: 10px;
}

.risk-card {
  background: #ffe2a4;
  color: #6b3c0c;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  text-align: center;
  border-right: 12px solid #ffaa33;
  padding-left: 10px;
  padding-right: 20px;
}

.risk-card div:first-child {
  font-weight: 800;
  margin-bottom: 6px;
  font-size: 1.1em;
}

.risk-card div:last-child {
  font-size: 0.92rem !important;
  font-weight: 600;
  line-height: 1.35;
  color: #5a3208;
}

.scenario-card.selected {
  background: #ff9bc2;
  color: #2d0d1c;
  transform: scale(1.02);
  box-shadow: 0 6px 0 #c7517a;
  border-left: 12px solid white;
}

.risk-card.selected {
  background: #ffb347;
  color: white;
  transform: scale(1.02);
  box-shadow: 0 6px 0 #b4622a;
  border-right: 12px solid white;
}

.scenario-card.matched,
.risk-card.matched {
  display: none;
}

.scenario-card.error,
.risk-card.error {
  background: #ffcccc !important;
  border-color: #ff4d4f !important;
  color: #a8071a !important;
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  transform: translate3d(0, 0, 0);
  box-shadow: 0 6px 0 #cf1322 !important;
}

.scenario-card.success,
.risk-card.success {
  background: #d9f7be !important;
  border-color: #52c41a !important;
  color: #237804 !important;
  box-shadow: 0 6px 0 #389e0d !important;
  transform: scale(1.05);
  transition: all 0.3s ease;
}

.message-area,
.teacher-message,
.empty-state {
  background: #fffbe6;
  border-radius: 32px;
  padding: 14px 20px;
  font-weight: 600;
  color: #bb6b2e;
  border-left: 12px solid #ffb347;
  margin-bottom: 16px;
  font-size: 0.94rem;
}

.footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.74rem;
  color: #a6561c;
  background: #fff1da;
  border-radius: 60px;
  padding: 12px;
}

.register-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 234, 206, 0.7);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.register-card {
  width: 100%;
  max-width: 520px;
  background: rgba(255, 250, 242, 0.96);
  border-radius: 42px;
  padding: 28px 24px;
  border: 4px solid #ffd59e;
  box-shadow: 0 20px 36px rgba(0, 0, 0, 0.16);
}

.register-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  color: #ff5e73;
  margin-bottom: 10px;
}

.register-subtitle {
  text-align: center;
  color: #a96a2e;
  font-size: 1rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.register-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  color: #8d4f18;
  font-weight: 800;
  padding-left: 6px;
}

.cute-input {
  width: 100%;
  border: 2px solid #ffd19d;
  background: #fff7ed;
  border-radius: 20px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: #6d390d;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.cute-input:focus {
  border-color: #ff8b68;
  box-shadow: 0 0 0 4px rgba(255, 157, 92, 0.2);
}

.register-tip,
.inline-tip {
  text-align: center;
  color: #ab6a31;
  font-size: 0.92rem;
  line-height: 1.5;
}

.tip-error {
  color: #cf3d32;
}

.tip-success {
  color: #2f9b3c;
}

.victory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.victory-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.victory-card {
  background: #fff;
  padding: 40px;
  border-radius: 40px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  transform: scale(0.8);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 90%;
  width: 420px;
  border: 5px solid #ffbc6e;
}

.victory-overlay.show .victory-card {
  transform: scale(1);
}

.victory-title {
  font-size: 2.5rem;
  color: #ff3e6c;
  margin-bottom: 10px;
  font-weight: 900;
}

.victory-text {
  font-size: 1.05rem;
  color: #555;
  margin-bottom: 25px;
  line-height: 1.6;
}

.victory-btn {
  padding: 12px 30px;
  font-size: 1.1rem;
}

.teacher-grid,
.leaderboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}

.teacher-card,
.leaderboard-card {
  background: rgba(255, 249, 239, 0.95);
  border: 3px solid #ffd9aa;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.08);
}

.teacher-card h2,
.leaderboard-card h2 {
  background: linear-gradient(135deg, #ffe2bc, #ffd39e);
  color: #935217;
  border-bottom: 4px dashed #efb26c;
}

.table-wrap {
  overflow-x: auto;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  min-width: 760px;
}

.rank-table th,
.rank-table td {
  padding: 14px 12px;
  text-align: center;
  border-bottom: 1px dashed #f1c78e;
  color: #7a4619;
  font-weight: 700;
}

.rank-table th {
  background: #fff1db;
  color: #a15f1f;
  position: sticky;
  top: 0;
}

.rank-table tbody tr:nth-child(odd) {
  background: rgba(255, 244, 225, 0.65);
}

.rank-table tbody tr:hover {
  background: rgba(255, 233, 201, 0.9);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ff9a3d, #ff5f76);
  box-shadow: 0 6px 10px rgba(255, 95, 118, 0.25);
}

.rank-badge.gold {
  background: linear-gradient(135deg, #f5bf2f, #f78a1c);
}

.rank-badge.silver {
  background: linear-gradient(135deg, #bfc9d7, #8692a6);
}

.rank-badge.bronze {
  background: linear-gradient(135deg, #de9d64, #b56c2e);
}

.student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.rank-avatar,
.teacher-student-avatar {
  width: 46px;
  height: 46px;
  border-width: 3px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.status-finished {
  background: #d8f7db;
  color: #217132;
}

.status-pending {
  background: #fff2cf;
  color: #8b6113;
}

.status-submitted {
  background: #dff2ff;
  color: #21658b;
}

.mono-text {
  font-family: "Consolas", "Courier New", monospace;
}

.qrcode-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px;
}

#teacherQrcode {
  background: #fff;
  padding: 12px;
  border-radius: 24px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
}

.share-link-box,
.live-link-box {
  background: #fff7eb;
  border: 2px dashed #f0bf7d;
  border-radius: 22px;
  padding: 14px 16px;
  font-weight: 700;
  color: #8a5019;
  line-height: 1.6;
  word-break: break-all;
}

.student-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.student-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #fff4e6;
  border: 2px solid #ffd9aa;
  border-radius: 24px;
  padding: 12px 14px;
}

.student-list-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.student-list-item-meta {
  color: #a6662e;
  font-size: 0.88rem;
  margin-top: 4px;
}

.timestamp-text {
  color: #9e6b39;
  font-size: 0.84rem;
}

.empty-state {
  text-align: center;
  border-left-width: 0;
  padding: 28px 16px;
}

@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

@media (max-width: 980px) {
  body {
    padding: 12px;
    align-items: flex-start;
  }

  .teacher-grid,
  .leaderboard-grid {
    grid-template-columns: 1fr;
  }

  .game-container,
  .teacher-panel,
  .leaderboard-panel {
    border-radius: 28px;
    padding: 16px 12px 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  }

  .player-banner,
  .teacher-topbar,
  .leaderboard-topbar,
  .stats,
  .summary-cards,
  .teacher-meta-grid {
    border-radius: 22px;
    padding: 12px;
  }

  .game-header h1,
  .teacher-header h1,
  .leaderboard-header h1 {
    font-size: 1.8rem;
  }

  .game-board {
    flex-direction: column;
    gap: 20px;
    margin: 10px 0;
  }

  .column,
  .teacher-card,
  .leaderboard-card {
    width: 100%;
    min-width: auto;
    padding: 15px 10px;
    border-radius: 25px;
  }

  .column h2,
  .teacher-card h2,
  .leaderboard-card h2 {
    font-size: 1.35rem;
    margin-bottom: 15px;
    padding: 8px 0;
  }

  .stats,
  .summary-cards,
  .teacher-meta-grid,
  .player-banner,
  .teacher-topbar,
  .leaderboard-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .matched-counter,
  .stats-text,
  .remaining-info,
  .reset-btn,
  .refresh-btn,
  .nav-btn,
  .export-btn,
  .teacher-action-btn,
  .secondary-btn,
  .summary-card,
  .teacher-meta-card {
    width: 100%;
    text-align: center;
  }

  .scenario-card,
  .risk-card {
    height: auto;
    min-height: 92px;
    padding: 12px;
  }

  .scenario-card {
    font-size: 0.9rem;
    padding-left: 15px;
    line-height: 1.3;
  }

  .risk-card {
    font-size: 1rem;
    padding-right: 15px;
  }

  .risk-card div:last-child {
    font-size: 0.82rem !important;
    line-height: 1.25;
  }

  .message-area,
  .teacher-message,
  .empty-state,
  .footer,
  .register-tip,
  .inline-tip {
    font-size: 0.85rem;
  }

  .register-card {
    padding: 22px 16px;
    border-radius: 28px;
  }

  .register-title {
    font-size: 1.6rem;
  }

  .rank-table {
    min-width: 620px;
  }
}

@media (max-width: 480px) {
  .game-header h1,
  .teacher-header h1,
  .leaderboard-header h1 {
    font-size: 1.45rem;
  }

  .scenario-card,
  .risk-card {
    min-height: 84px;
    font-size: 0.84rem;
  }

  .risk-card div:last-child {
    font-size: 0.76rem !important;
  }

  .rank-avatar,
  .teacher-student-avatar {
    width: 52px;
    height: 52px;
  }
}
