/* tragedy-of-the-commons/style.css */

/* Global Custom Properties & Palette */
:root {
  --font-main: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  
  /* Question Repair Shop-inspired classroom palette */
  --bg-page: #f3f6fc;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-bg-strong: #ffffff;
  --panel-border: #e3eaf3;
  --panel-border-strong: #bfdbfe;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Lake States (Blue/Green -> Orange -> Red -> Black/Gray) */
  --lake-healthy-start: #0ea5e9;
  --lake-healthy-end: #14b8a6;
  --lake-warning-start: #f59e0b;
  --lake-warning-end: #ea580c;
  --lake-danger-start: #ef4444;
  --lake-danger-end: #b91c1c;
  --lake-dead-start: #64748b;
  --lake-dead-end: #334155;

  /* Button & Alert Colors */
  --btn-primary: #2563eb;
  --btn-primary-hover: #1d4ed8;
  --btn-secondary: #f1f5f9;
  --btn-secondary-hover: #e2e8f0;
  --btn-danger: #dc2626;
  
  --accent-gold: #d97706;
  --accent-silver: #64748b;
  --accent-bronze: #c2410c;
  --accent-blue: #2563eb;
  --accent-teal: #0f766e;

  --transition-speed: 0.3s;
}

.site-legal {
  width: 100%;
  margin-top: 14px;
  text-align: center;
  font-size: 0.75rem;
}

.site-legal a {
  color: var(--text-muted);
  opacity: 0.72;
  text-underline-offset: 3px;
}

.site-legal a:hover {
  opacity: 1;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 24px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-container {
  width: 100%;
  max-width: 1400px;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Glassmorphism utility */
.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(18px) saturate(110%);
  -webkit-backdrop-filter: blur(18px) saturate(110%);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 12px 34px rgba(30, 64, 175, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Typography & Helpers */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-center { text-align: center; }
.text-danger { color: #f87171 !important; }
.text-success { color: #4ade80 !important; }
.text-warning { color: #facc15 !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.mt-2 { margin-top: 8px; }
.hidden { display: none !important; }
.flex-column { display: flex; flex-direction: column; }
.flex-fill { flex: 1; }

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-weight: 700;
  border: none;
  border-radius: 13px;
  padding: 11px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--btn-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

.btn-outline {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
}
.btn-outline:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #93c5fd;
}

.btn-warning {
  background: #f8d477;
  color: #241704;
}
.btn-warning:hover:not(:disabled) {
  background: #f3c45f;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--btn-danger);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-light {
  background: #f3f4f6;
  color: #111827;
}
.btn-light:hover:not(:disabled) {
  background: #ffffff;
}

.btn-large {
  padding: 17px 30px;
  font-size: 1.12rem;
  border-radius: 15px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  font-size: 1.5rem;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Screens control */
.screen {
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

/* 1. SETUP SCREEN */
#setup-screen {
  justify-content: center;
  align-items: center;
  flex: 1;
}

.setup-card {
  width: 100%;
  max-width: 860px;
  padding: 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.45);
  outline-offset: 3px;
}

.setup-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: #2563eb;
}

.setup-header h1 {
  font-size: 3.4rem;
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
  margin-top: 14px;
  letter-spacing: -0.045em;
}

.setup-header h2 {
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 38px;
  letter-spacing: -0.015em;
}

.setup-header .logo-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 28px;
  display: grid;
  place-items: center;
  font-size: 3.4rem;
  background: #eff6ff;
  border: 1px solid rgba(103, 232, 249, 0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 16px 35px rgba(0, 0, 0, 0.18);
  animation: float 4s ease-in-out infinite;
}

.setup-grid {
  display: flex;
  justify-content: center;
  gap: 24px;
  text-align: left;
  margin-bottom: 36px;
}

.setup-grid .input-group {
  min-width: 320px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 1rem;
  font-weight: 650;
  color: #d8e8ed;
  margin-bottom: 3px;
}

.input-group select {
  font-family: var(--font-main);
  font-size: 1.1rem;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  color: white;
  outline: none;
  cursor: pointer;
}

.input-group select option {
  background: #111827;
  color: white;
}

/* Stepper (number control) */
.number-stepper {
  display: flex;
  align-items: center;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid var(--panel-border);
  border-radius: 15px;
  overflow: hidden;
}

.number-stepper button {
  width: 58px;
  height: 56px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.number-stepper button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.number-stepper input {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  color: white;
  font-size: 1.45rem;
  font-weight: 700;
  width: 100%;
  outline: none;
}

/* Hide spin buttons in number inputs */
.number-stepper input::-webkit-outer-spin-button,
.number-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.setup-actions {
  display: flex;
  justify-content: center;
}

/* 2. GAME SCREEN */
#game-screen {
  gap: 20px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-radius: 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back-setup {
  flex: 0 0 auto;
  white-space: nowrap;
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 700;
}

.btn-back-setup:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.brand-title {
  font-size: 1.55rem;
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
}

.current-policy-tag {
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(45, 212, 191, 0.09);
  border: 1px solid rgba(94, 234, 212, 0.2);
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-block;
  color: #99f6e4;
  margin-top: 4px;
}

.header-stats {
  display: flex;
  gap: 10px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--panel-border);
  padding: 8px 20px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

.stat-box.border-accent {
  border-color: rgba(94, 234, 212, 0.26);
  background: rgba(20, 184, 166, 0.06);
}

.lesson-progress-box {
  min-width: 220px;
}

.lesson-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-top: 8px;
}

.lesson-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: #2563eb;
  width: 0%;
  transition: width 0.4s ease;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 900;
}

.stat-value.badge {
  font-size: 1.3rem;
  margin-top: 4px;
}

/* Main Grid Layout */
.game-main-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

/* Lake Visualization Panel */
.lake-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lake-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.capacity-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.lake-header-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.lake-header-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.lake-header-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lake-header-stat-value {
  font-size: 1.15rem;
  font-weight: 800;
}

.canvas-container {
  position: relative;
  flex: 1;
  min-height: 380px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 0 32px rgba(0,0,0,0.28), 0 14px 34px rgba(0, 8, 16, 0.18);
  background: #0c3a4d; /* Base water color before load */
  border: 1px solid rgba(125, 211, 252, 0.12);
}

#lake-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#lake-overlay-msg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.alert-box {
  max-width: 450px;
  text-align: center;
  padding: 30px;
  border-radius: 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #ef4444;
  animation: pulse-border 2s infinite;
}

.alert-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}

.alert-box h2 {
  font-size: 1.8rem;
  color: #f87171;
  margin-bottom: 8px;
}

.alert-box p {
  color: #e5e7eb;
  margin-bottom: 20px;
}

.alert-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Timer and Negotiation Clock */
.timer-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.025);
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
}

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

.timer-icon {
  font-size: 1.5rem;
}

.timer-title {
  font-size: 1.05rem;
  color: #e5e7eb;
}

.timer-clock {
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-gold);
  background: rgba(246, 201, 107, 0.08);
  border: 1px solid rgba(246, 201, 107, 0.15);
  padding: 2px 12px;
  border-radius: 8px;
  letter-spacing: 0.05em;
}

.timer-controls {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap; /* 줄바꿈 절대 차단 */
}

.timer-controls .btn {
  white-space: nowrap; /* 글자 1줄 유지 */
  font-size: 0.82rem; /* 화면 너비에 최적화된 크기 */
  padding: 6px 12px; /* 가로 공간을 아끼는 여백 */
}

/* Right Control Panel */
.control-panel {
  gap: 20px;
}

.panel-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card-header {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 14px;
}

.panel-card-header h3,
.lake-card-header h3,
.section-header h3 {
  font-size: 1.08rem;
  color: #eaf7f9;
}

.shortcut-tip {
  font-size: 0.8rem;
  color: #7dd3fc;
  display: block;
  margin-top: 4px;
}

.input-panel-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding-right: 8px;
}

/* Dynamic Team Inputs List */
.team-inputs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.025);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(190, 220, 228, 0.08);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.team-input-row.focused {
  background: rgba(45, 212, 191, 0.08);
  border-color: rgba(94, 234, 212, 0.42);
  box-shadow: 0 8px 24px rgba(0, 12, 20, 0.2);
}

.team-name-badge {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444; /* red for unentered */
  display: inline-block;
  box-shadow: none;
}

.team-input-row.entered .team-status-dot {
  background: #10b981; /* green for entered */
  box-shadow: none;
}

.team-cumulative-score {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* Radio button toggles for 1, 2, 3 boats */
.boat-selectors {
  display: flex;
  gap: 8px;
}

.boat-radio-btn {
  display: none;
}

.boat-label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 54px;
  height: 54px;
  border-radius: 13px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  position: relative;
}

.boat-label:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.boat-radio-btn:checked + .boat-label {
  border-color: #5eead4;
  background: #eff6ff;
  color: white;
  box-shadow: 0 8px 20px rgba(0, 12, 20, 0.18);
  transform: translateY(-1px);
}

/* Boat Icons inside labels */
.boat-label::after {
  content: "⛵";
  font-size: 0.6rem;
  margin-top: 2px;
  opacity: 0.6;
}

.boat-label[data-val="2"]::after {
  content: "⛵⛵";
}

.boat-label[data-val="3"]::after {
  content: "⛵⛵⛵";
  font-size: 0.55rem;
}

/* Red style for active high selections (greed marker) */
.boat-radio-btn[value="3"]:checked + .boat-label {
  border-color: #f87171;
  background: #fef2f2;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.3);
}

/* Regulation phase (turns 7-9): marks choices above the limit as fine-risk, not blocked */
.boat-label.fine-risk {
  border: 2px dashed #f59e0b;
  color: #fbbf24;
}

.boat-radio-btn:checked + .boat-label.fine-risk {
  border-style: solid;
  background: #fffbeb;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

/* Policy Phase Timeline (status display only - auto-progresses with the turn) */
.policy-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.policy-card {
  font-family: var(--font-main);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 13px 7px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all var(--transition-speed);
}

.policy-card.completed {
  opacity: 0.55;
}

.policy-card.completed .policy-name::after {
  content: " ✓";
}

.policy-card.active {
  border-color: rgba(94, 234, 212, 0.4);
  background: #f0fdf4;
  color: white;
  box-shadow: 0 10px 24px rgba(0, 12, 20, 0.16);
}

.policy-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.policy-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.policy-desc {
  font-size: 0.72rem;
  margin-top: 2px;
  opacity: 0.85;
}

/* Active Policy Config Settings Box */
.policy-settings-box {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 14px;
  padding: 14px;
  margin-top: 8px;
  font-size: 0.9rem;
  animation: fadeIn 0.3s;
}

.policy-settings-box label {
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
  color: #34d399;
}

.policy-settings-box input[type="number"] {
  width: 70px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 4px 8px;
  color: white;
  font-weight: bold;
}

.policy-settings-box .form-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* History Section */
.history-section {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.95rem;
}

.history-table th, .history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(190, 220, 228, 0.08);
}

.history-table th {
  background: rgba(255, 255, 255, 0.045);
  font-weight: 700;
  color: #e5e7eb;
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* Special styling for individual team values in history */
.history-table td.team-cell {
  border-left: 1px solid rgba(255, 255, 255, 0.03);
}

/* 3. MODAL OVERLAY */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(1, 10, 16, 0.82);
  backdrop-filter: blur(12px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 90%;
  max-width: 700px;
  max-height: 88vh;
  padding: 32px;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Keep header/footer always visible; only the body scrolls when content
   (e.g. many hidden teams during the regulation/monitoring phase) overflows */
.modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-content.max-w-sm {
  max-width: 480px;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
}
.close-btn:hover {
  color: white;
}

.modal-header {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.8rem;
  background: none;
  color: #b45309;
  -webkit-text-fill-color: currentColor;
}

.turn-summary-block {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--panel-border);
  text-align: center;
}

.summary-highlight {
  font-size: 1.8rem;
  font-weight: 800;
  color: #67e8f9;
  margin-bottom: 12px;
}

.summary-details p {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.next-fish-highlight {
  font-size: 1.25rem;
  font-weight: bold;
  color: #34d399;
  margin-top: 10px;
}

.team-results-block h3 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: #e5e7eb;
}

.modal-team-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  margin-bottom: 20px;
}

.modal-team-table th, .modal-team-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.modal-team-table th {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modal-team-table td {
  font-size: 1.05rem;
  font-weight: bold;
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #bae6fd;
}

.agreement-announcement {
  font-size: 1.2rem;
  line-height: 1.6;
  background: rgba(52, 211, 153, 0.05);
  border: 1.5px solid rgba(52, 211, 153, 0.3);
  padding: 20px;
  border-radius: 16px;
  color: white;
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* 4. FINAL RESULT SCREEN */
#result-screen {
  padding: 20px 0;
}

.result-card {
  padding: 40px;
  width: 100%;
}

.result-header {
  text-align: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 24px;
  margin-bottom: 30px;
}

.result-header h1 {
  font-size: 2.8rem;
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
}

.result-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.result-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
}

.result-stat-card.border-accent {
  border-color: rgba(239, 68, 68, 0.4);
}

.result-stat-card h3 {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.result-stat-large {
  font-size: 2.4rem;
  font-weight: 900;
  display: block;
}

.result-stat-sub {
  font-size: 0.95rem;
  margin-top: 6px;
}

.stats-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
  padding-bottom: 6px;
}

.stats-list li:last-child {
  border: none;
}

.stat-li-label {
  color: var(--text-muted);
}

.stat-li-val {
  font-weight: bold;
}

/* Leaderboard */
.leaderboard-section {
  margin-bottom: 40px;
}

.leaderboard-section h2 {
  font-size: 1.6rem;
  margin-bottom: 20px;
  border-left: 4px solid #34d399;
  padding-left: 12px;
}

.leaderboard-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--panel-border);
}

.leaderboard-rank {
  font-size: 1.6rem;
  font-weight: 900;
  width: 50px;
}

.leaderboard-rank.rank-1 { color: var(--accent-gold); }
.leaderboard-rank.rank-2 { color: var(--accent-silver); }
.leaderboard-rank.rank-3 { color: var(--accent-bronze); }

.leaderboard-team-name {
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
}

.leaderboard-bar-wrapper {
  flex: 2;
  margin: 0 40px;
}

.leaderboard-bar-outer {
  height: 12px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}

.leaderboard-bar-inner {
  height: 100%;
  border-radius: 99px;
  background: #2563eb;
  width: 0%;
  transition: width 1s ease-out;
}

.leaderboard-item:nth-child(1) .leaderboard-bar-inner {
  background: #f59e0b;
}

.leaderboard-score {
  font-size: 1.4rem;
  font-weight: 900;
  width: 120px;
  text-align: right;
}

/* Discussion Grid */
.discussion-section {
  margin-bottom: 40px;
}

.discussion-section h2 {
  font-size: 1.6rem;
  margin-bottom: 20px;
  border-left: 4px solid #fbbf24;
  padding-left: 12px;
}

.discussion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.question-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  gap: 16px;
}

.q-num {
  font-family: var(--font-main);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-gold);
  line-height: 1;
}

.question-card p {
  font-size: 1rem;
  line-height: 1.6;
  color: #e5e7eb;
}

.question-card strong {
  color: #fbbf24;
}

.result-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
}

/* Animations */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-border {
  0% { border-color: rgba(239, 68, 68, 0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { border-color: rgba(239, 68, 68, 0.2); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { border-color: rgba(239, 68, 68, 0.8); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.animate-pop {
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Print/Export Styling overrides */
@media print {
  body {
    background: white !important;
    color: black !important;
    padding: 0;
  }
  .app-container {
    max-width: 100%;
    box-shadow: none !important;
  }
  .glass {
    background: transparent !important;
    backdrop-filter: none !important;
    border: 1px solid #ccc !important;
    color: black !important;
    box-shadow: none !important;
  }
  .screen {
    display: none !important;
  }
  #game-screen.screen.active {
    display: flex !important;
  }
  .timer-section, .policy-selector-grid, .panel-actions, .header-left button, #btn-export-capture, .policy-settings-box {
    display: none !important;
  }
  .game-main-layout {
    grid-template-columns: 1fr !important;
  }
  .lake-card {
    display: none !important;
  }
  .control-panel {
    display: none !important;
  }
  .history-section {
    display: block !important;
    page-break-inside: avoid;
  }
  th {
    background: #eee !important;
    color: black !important;
  }
  td, th {
    border-bottom: 1px solid #aaa !important;
  }
}

/* Stepper Custom */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

/* Custom Scrollbar for dynamic panels */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Timer Alert blink animation */
.timer-clock.timer-alert {
  background: #dc2626 !important;
  color: #ffffff !important;
  box-shadow: 0 0 15px #dc2626;
  animation: timer-blink-anim 0.5s infinite alternate;
}

@keyframes timer-blink-anim {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

/* Greed and Coop badges */
.badge-greedy {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-coop {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Lake Gauge inside turn result modal */
.lake-gauge-container {
  margin: 15px 0;
  text-align: left;
}

.lake-gauge-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.lake-gauge-outer {
  height: 20px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
}

.lake-gauge-inner {
  height: 100%;
  border-radius: 99px;
  background: #2563eb;
  width: 100%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dynamic colors for gauge inside result modal */
.lake-gauge-inner.healthy {
  background: #0ea5e9;
}
.lake-gauge-inner.warning {
  background: #f59e0b;
}
.lake-gauge-inner.danger {
  background: #ef4444;
}
.lake-gauge-inner.dead {
  background: #4b5563;
}

/* Inspect button styling */
.btn-inspect {
  background: #f59e0b;
  border: none;
  border-radius: 6px;
  color: #111827;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
}

.btn-inspect:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.5);
}

.anonymous-box {
  background: rgba(0,0,0,0.3);
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s;
}

.anonymous-box.revealed-pulse {
  border: 1px solid #34d399;
  background: rgba(52, 211, 153, 0.05);
  animation: reveal-pulse-anim 0.8s 1;
}

@keyframes reveal-pulse-anim {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 15px 5px rgba(52, 211, 153, 0.3); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* Execute turn pulse when all entered */
@keyframes button-pulse {
  0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

#btn-execute-turn.pulse-ready {
  animation: button-pulse 1.8s infinite;
  background: #2563eb;
  border: 1px solid rgba(255,255,255,0.2);
}

/* 비밀 입력 가림막 모드 (Input Masking styles) */
.boat-selectors-wrapper {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 260px;
}

.mask-overlay-layer {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0f172a !important; /* 뚫어볼 수 없게 100% 불투명한 짙은 네이비 배경 적용 */
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: bold;
  font-size: 0.95rem;
  align-items: center;
  justify-content: center;
  z-index: 1000 !important; /* z-index를 최상위로 끌어올려 라벨 하이라이트가 튀어나오지 못하게 차단 */
  cursor: default;
  transition: all 0.2s;
  user-select: none;
}

/* 가림막 모드 시 레이어 노출 */
.team-inputs-list.mask-active .mask-overlay-layer {
  display: flex;
}

/* 입력 완료 시 황금색 자물쇠 레이어로 변신 */
.team-inputs-list.mask-active .team-input-row.entered .mask-overlay-layer {
  background: #1e1b4b !important; /* 투명도 없는 불투명 황금 자물쇠 박스 배경 적용 */
  border: 1.5px solid rgba(245, 158, 11, 0.6);
  color: #fbbf24;
  cursor: pointer;
}

.team-inputs-list.mask-active .team-input-row.entered .mask-overlay-layer:hover {
  background: #2e1065 !important;
  transform: scale(1.02);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

/* 가림막 활성화 상태에서 임시 공개 상태가 아닐 때 내부 보트 버튼들은 원천 가림 */
.team-inputs-list.mask-active .team-input-row .boat-selectors {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Ensure relative position on row for absolute indicator */
.team-input-row {
  position: relative;
}

/* 2026 light classroom theme — aligned with 질문수리소 */
.text-danger { color: #dc2626 !important; }
.text-success { color: #059669 !important; }
.text-warning { color: #b45309 !important; }

.btn-outline {
  color: #475569;
}

.btn-icon {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
}

.btn-icon:hover {
  background: #e2e8f0;
}

.btn-light {
  background: #f1f5f9;
  color: #0f172a;
}

#btn-open-guide,
#btn-open-projector {
  color: #2563eb !important;
  border-color: #bfdbfe !important;
  background: #eff6ff !important;
}

#btn-open-rules,
#btn-header-rules {
  color: #475569 !important;
  border-color: #cbd5e1 !important;
  background: #ffffff !important;
}

.setup-card::before {
  background: #2563eb;
}

.setup-header h1 {
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
}

.setup-header h2 {
  color: #64748b;
}

.setup-header .logo-icon {
  background: #eff6ff;
  border-color: #dbeafe;
  box-shadow: inset 0 1px 0 #ffffff, 0 14px 28px rgba(37, 99, 235, 0.1);
}

.input-group label,
.timer-title,
.team-results-block h3,
.question-card p {
  color: #334155;
}

.number-stepper,
.input-group select {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.number-stepper button {
  background: #eff6ff;
  color: #1d4ed8;
  border-right: 1px solid #dbeafe;
  border-left: 1px solid #dbeafe;
}

.number-stepper button:hover {
  background: #dbeafe;
}

.number-stepper input {
  color: #0f172a;
}

.game-header {
  background: rgba(255, 255, 255, 0.97);
}

.brand-title {
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
}

.current-policy-tag {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.stat-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.stat-box.border-accent {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.lesson-progress-track,
.leaderboard-bar-outer,
.lake-gauge-outer {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.lesson-progress-fill,
.leaderboard-bar-inner {
  background: #2563eb;
}

.lake-card-header h3,
.panel-card-header h3,
.section-header h3 {
  color: #0f172a;
}

.capacity-info,
.lake-header-stat-label,
.shortcut-tip,
.stat-label {
  color: #64748b;
}

.shortcut-tip {
  color: #2563eb;
}

.timer-section {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.timer-clock {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

.panel-card-header,
.result-header,
.modal-header {
  border-color: #e2e8f0;
}

.team-input-row {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.team-input-row.focused {
  background: #eff6ff;
  border-color: #60a5fa;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.1);
}

.boat-label {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}

.boat-label:hover {
  background: #f8fafc;
  border-color: #93c5fd;
}

.boat-radio-btn:checked + .boat-label {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.policy-card {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

.policy-card.active {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
  box-shadow: 0 8px 20px rgba(22, 101, 52, 0.08);
}

.policy-settings-box {
  background: #f8fafc;
  border-color: #bbf7d0;
  color: #334155;
}

.policy-settings-box label {
  color: #047857;
}

.policy-settings-box input[type="number"] {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.table-container {
  border-color: #e2e8f0;
}

.history-table th {
  background: #f8fafc;
  color: #334155;
}

.history-table th,
.history-table td,
.modal-team-table th,
.modal-team-table td {
  border-color: #e2e8f0;
}

.history-table tr:hover td {
  background: #f8fafc;
}

.modal-overlay {
  background: rgba(15, 23, 42, 0.48);
}

.modal-content {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
}

.close-btn {
  color: #64748b;
}

.close-btn:hover {
  color: #0f172a;
}

.turn-summary-block,
.result-stat-card,
.leaderboard-item,
.question-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.summary-highlight {
  color: #2563eb;
}

.next-fish-highlight {
  color: #047857;
}

.modal-team-table th {
  color: #64748b;
}

.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.agreement-announcement {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #14532d;
}

.result-card {
  background: rgba(255, 255, 255, 0.97);
}

.result-header h1 {
  background: none;
  color: #2563eb;
  -webkit-text-fill-color: currentColor;
}

.leaderboard-section h2 {
  border-left-color: #2563eb;
}

.discussion-section h2 {
  border-left-color: #f59e0b;
}

.question-card strong,
.q-num {
  color: #b45309;
}

.badge-greedy {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.badge-coop {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.anonymous-box {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

::-webkit-scrollbar-track {
  background: #eef2f7;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}



/* Desktop workspace: keep controls usable on short laptop displays. */
@media screen {
  body { padding: clamp(12px, 1.4vw, 24px); align-items: flex-start; }
  .app-container { max-width: 1920px; }
  .game-header { gap: 16px; flex-wrap: wrap; }
  .header-left { flex: 1 1 560px; min-width: 0; }
  .header-stats { flex-wrap: wrap; }
  #btn-open-projector { margin-left: 0 !important; }
  .game-main-layout { grid-template-columns: minmax(0, 1.15fr) minmax(390px, 1fr); align-items: stretch; }
  .lake-card, .control-panel, .panel-card, .history-section { min-width: 0; }
  .lake-card-header, .timer-section, .section-header { flex-wrap: wrap; gap: 12px; }
  .timer-controls { flex-wrap: wrap; }
  .canvas-container { min-height: 260px; }
  #lake-canvas { position: absolute; inset: 0; }
  .boat-selectors-wrapper { min-width: 0; flex-shrink: 0; }
  .team-input-row { gap: 12px; padding: 8px 12px; }
  .team-name-badge { flex-wrap: wrap; }
  .history-table { white-space: nowrap; }
  .table-container { max-height: 380px; }
  .history-table th { position: sticky; top: 0; z-index: 1; }
  .modal-overlay { padding: 16px; z-index: 2000; }
  .modal-content { width: 100%; max-height: calc(100dvh - 32px); padding: 24px; }
  .modal-header, .modal-footer { flex-shrink: 0; }
  .modal-header { padding-right: 28px; }
  .modal-footer { gap: 12px; flex-wrap: wrap; }
  .team-results-block { overflow-x: auto; }
  .modal-team-table { min-width: 480px; }
  #result-modal .modal-content { max-width: 1100px; }
  .boat-label.fine-risk { color: #92400e; }
  .result-actions { flex-wrap: wrap; }
  .result-stat-card { min-width: 0; }
}
@media screen and (min-width: 1100px) {
  #result-modal .modal-body, #projector-result-modal .modal-body {
    display: grid; grid-template-columns: minmax(230px, .8fr) minmax(0, 1.6fr); gap: 20px; align-items: start;
  }
  .turn-summary-block { margin-bottom: 0; }
  #modal-anonymity-msg { grid-column: 1 / -1; }
}
@media screen and (min-width: 900px) and (max-height: 850px) {
  #game-screen { gap: 12px; }
  .game-header, .lake-card, .panel-card { padding: 14px; }
  .control-panel, .panel-card, .lake-card { gap: 10px; }
  .input-panel-scroll { max-height: 230px; }
  .policy-card { padding: 7px 4px; }
  .policy-icon { font-size: 1.2rem; }
  .btn-large { padding: 12px 18px; }
}
@media screen and (max-width: 899px) {
  .game-main-layout { grid-template-columns: minmax(0, 1fr); }
  .canvas-container { height: 300px; flex: none; }
  .result-dashboard { grid-template-columns: 1fr; }
  .discussion-grid { grid-template-columns: 1fr; }
  .setup-card, .result-card { padding: 24px; }
  .setup-grid .input-group { min-width: 0; width: 100%; }
  .setup-header h1 { font-size: 2.5rem; }
  .leaderboard-bar-wrapper { margin: 0 12px; }
}

/* Student display: use the width of 16:9, 16:10 and 4:3 projectors. */
@media screen {
  body.projector-view { display: block; padding: 16px; }
  .projector-body-container { width: 100%; margin: 0 auto; }
  .projector-view #game-screen { display: grid !important; grid-template-columns: minmax(0, 1.5fr) minmax(350px, 1fr); grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - 32px); gap: 16px; }
  .projector-view .game-header { grid-column: 1 / -1; padding: 12px 20px; }
  .projector-view .header-left { flex-basis: 350px; }
  .projector-view .brand-title { font-size: clamp(22px, 1.7vw, 34px); }
  .projector-view .stat-value { font-size: clamp(22px, 2vw, 36px); }
  .projector-view .game-main-layout { display: flex; min-height: 0; }
  .projector-view .lake-card { width: 100%; min-height: 0; padding: 16px; }
  .projector-view .canvas-container { min-height: 120px; height: auto; flex: 1; }
  .projector-view .lake-card-header { align-items: flex-start; flex-direction: column; }
  .projector-view .lake-header-stat-value { font-size: clamp(28px, 2.8vw, 48px); }
  .projector-view .lake-header-stat-label, .projector-view .capacity-info { font-size: 16px; }
  .projector-view .timer-section { justify-content: center; }
  .projector-view .timer-clock { font-size: clamp(28px, 3vw, 48px); }
  .projector-view .history-section { min-height: 0; padding: 16px; gap: 12px; }
  .projector-view .table-container { max-height: none; overflow: auto; }
  .projector-view .history-table { white-space: normal; table-layout: fixed; }
  .projector-view .history-table th, .projector-view .history-table td { padding: 10px 3px; font-size: clamp(14px, 1.1vw, 21px); overflow-wrap: anywhere; }
  .projector-view .modal-content { max-width: 1280px; }
  .projector-view .modal-team-table th, .projector-view .modal-team-table td { font-size: clamp(16px, 1.3vw, 24px); }
  .projector-view .summary-details { font-size: clamp(17px, 1.4vw, 24px); }
  .projector-view .control-panel { display: none; }
}
@media screen and (max-width: 899px) {
  .projector-view #game-screen { height: auto; min-height: calc(100dvh - 32px); grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .projector-view .canvas-container { min-height: 300px; }
  .projector-view .table-container { max-height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media screen {
  .projector-view .history-table th, .projector-view .history-table td { word-break: keep-all; overflow-wrap: normal; }
  .projector-view .history-table th:first-child { width: 12%; }
  .summary-details, .summary-highlight { word-break: keep-all; overflow-wrap: anywhere; }
}

.classroom-options { display: grid; gap: 16px; text-align: left; margin: 0 0 24px; }
.classroom-options label { display: grid; gap: 6px; font-weight: 700; }
.classroom-options select { width: 100%; min-width: 0; padding: 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: white; color: #0f172a; font: inherit; }
.classroom-options p { color: #475569; font-size: .9rem; }
.projector-controls { position: fixed; z-index: 4000; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px solid #93c5fd; border-radius: 14px; background: #fff; box-shadow: 0 4px 24px #0f172a33; width: max-content; max-width: calc(100% - 16px); }
#projector-page-status { font-weight: 700; font-size: .9rem; }
.has-projector { padding-bottom: 82px; }
.has-projector .modal-overlay { padding-bottom: 82px; }
.has-projector .modal-content { max-height: calc(100dvh - 100px); }
.phase-comparison { margin: 0 0 24px; }
.phase-comparison > p { margin: 8px 0 16px; color: #475569; }
.phase-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.student-page-caption { font-size: 16px; color: #475569; margin-top: 6px; }
.projector-view #projector-result-modal .modal-body { display: block; }
.projector-view #projector-result-modal .turn-summary-block { padding: 10px 14px; margin-bottom: 12px; }
.projector-view #projector-result-modal .lake-gauge-container { display: none; }
.projector-view #projector-result-modal .summary-highlight { font-size: 20px; margin-bottom: 4px; }
.projector-view #projector-result-modal .summary-highlight span { font-size: 24px !important; }
.projector-view #projector-result-modal .summary-details { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; font-size: 16px; }
.projector-view #projector-result-modal .summary-details p { margin: 0; }
.projector-view #projector-result-modal .modal-team-table { margin-bottom: 8px; }
.projector-view #projector-result-modal .modal-team-table td { padding: 8px; }
.projector-view #projector-result-modal .modal-header { margin-bottom: 12px; padding-bottom: 10px; }
.projector-view #projector-result-modal .alert-info { padding: 8px 12px; font-size: 14px; }
.projector-view .result-card { padding: 20px; }
.projector-view .result-header { margin-bottom: 16px; padding-bottom: 12px; }
.projector-view .leaderboard-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.projector-view .leaderboard-bar-wrapper { display: none; }
.projector-view .result-stat-card { padding: 16px; }
@media screen and (max-width: 899px) { .phase-summary-grid { grid-template-columns: 1fr; } }
@media print { .projector-controls, #btn-export-csv { display: none !important; } }

/* Illustrated classroom entrance, using the existing lake artwork. */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#setup-screen { width: 100%; padding: 20px 0; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(370px, 1fr); align-items: center; gap: clamp(24px, 3vw, 48px); width: 100%; max-width: 1480px; margin: auto; }
.setup-story { min-width: 0; }
.setup-eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 18px 4px; color: #315981; font-size: .85rem; font-weight: 650; letter-spacing: .02em; }
.setup-eyebrow > span { width: 7px; height: 7px; background: #167ba1; border-radius: 50%; }
.setup-lake-art { width: 100%; height: auto; display: block; border: 1px solid #d6e4ef; border-radius: 24px; box-shadow: 0 22px 48px -30px #315b9170; }
.setup-story-copy { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 26px 4px; }
.setup-story-copy h2 { font-size: clamp(22px, 2vw, 32px); line-height: 1.4; color: #123b62; letter-spacing: -.035em; }
.setup-story-copy p { color: #557087; font-size: .96rem; line-height: 1.8; word-break: keep-all; }
.setup-journey { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); border-top: 1px solid #d6e4ef; padding: 20px 4px 0; gap: 16px; }
.setup-journey li { display: flex; align-items: flex-start; gap: 12px; }
.setup-journey li > span { font-size: .8rem; color: #5183b1; padding-top: 3px; font-weight: 700; }
.setup-journey strong { display: block; font-size: .95rem; color: #234768; }
.setup-journey small { display: block; margin-top: 3px; font-size: .78rem; color: #60788c; }
.setup-layout .setup-card { max-width: none; padding: 30px; border-radius: 24px; text-align: left; background: #ffffffed; box-shadow: 0 20px 60px -30px #41679155; }
.setup-layout .setup-card::before { height: 4px; background: linear-gradient(90deg, #164fcc, #42afd1); }
.setup-layout .setup-header { margin-bottom: 24px; }
.setup-layout .setup-header h2 { margin: 5px 0 8px; font-size: 1.8rem; font-weight: 750; color: #143a62; letter-spacing: -.04em; }
.setup-kicker { color: #2563a5; font-size: .75rem; font-weight: 700; letter-spacing: .05em; }
.setup-intro { color: #64748b; font-size: .9rem; }
.setup-layout .setup-grid { margin-bottom: 20px; }
.setup-layout .setup-grid .input-group { width: 100%; min-width: 0; }
.setup-layout .input-group label, .setup-layout .classroom-options label { font-size: .9rem; color: #29445f; }
.setup-layout .number-stepper button { height: 48px; }
.setup-layout .number-stepper input { font-size: 1.25rem; }
.setup-layout .classroom-options { gap: 16px; margin-bottom: 24px; }
.setup-layout .classroom-options select { padding: 11px 8px; font-size: .82rem; border-color: #d9e3ed; background: #f8fafc; }
.setup-layout .classroom-options p { font-size: .78rem; line-height: 1.65; color: #60758b; }
.setup-layout .setup-actions { display: flex; flex-direction: column; gap: 10px; }
.setup-layout #btn-start-game { width: 100%; justify-content: space-between; padding: 15px 18px; font-size: 1rem; background: #1558c4; box-shadow: 0 6px 16px #1558c422; }
.setup-layout #btn-start-game:hover { background: #124aaa; }
.setup-help-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 3px; }
.setup-help-actions .btn { font-size: .83rem; padding: 10px; }
#setup-screen .site-legal { margin-top: 24px; }
@media screen and (min-width: 1000px) and (max-height: 820px) {
  #setup-screen { padding: 0; }
  .setup-layout { max-width: 1320px; }
  .setup-layout .setup-card { padding: 22px; }
  .setup-layout .setup-header { margin-bottom: 16px; }
  .setup-layout .classroom-options { gap: 12px; margin-bottom: 16px; }
  .setup-story-copy { padding: 18px 4px; }
  .setup-journey { padding-top: 14px; }
}
@media screen and (max-width: 999px) {
  .setup-layout { max-width: 760px; grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .setup-layout .setup-card { padding: 28px; }
  .setup-story-copy { padding: 20px 0; }
}
@media screen and (max-width: 540px) {
  #setup-screen { padding: 4px 0; }
  .setup-eyebrow { font-size: .73rem; margin-bottom: 12px; }
  .setup-lake-art { border-radius: 16px; }
  .setup-story-copy { display: block; padding: 16px 2px; }
  .setup-story-copy h2 { font-size: 23px; }
  .setup-story-copy p { margin-top: 10px; font-size: .87rem; }
  .setup-journey { gap: 8px; }
  .setup-journey li { display: block; }
  .setup-journey strong { font-size: .84rem; }
  .setup-journey small { font-size: .65rem; }
  .setup-layout .setup-card { padding: 22px 18px; }
}

/* Classroom header: identity, progress, then secondary actions. */
@media screen {
  .game-header { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 24px; padding: 16px 22px; }
  .game-header .header-left { min-width: 0; }
  .game-header .brand-title { font-size: 1.45rem; color: #174780; line-height: 1.25; }
  .header-subtitle { margin-top: 5px; color: #64748b; font-size: .8rem; }
  .game-header .header-stats { flex-wrap: nowrap; gap: 0; align-items: center; }
  .game-header .stat-box { min-width: 100px; padding: 0 20px; border: 0; border-radius: 0; background: transparent; align-items: flex-start; }
  .game-header .lesson-progress-box { min-width: 175px; border-left: 1px solid #dce5ef; }
  .game-header .stat-label { font-size: .72rem; }
  .game-header .stat-value { font-size: 1.35rem; line-height: 1.35; white-space: nowrap; }
  .game-header .stat-value.badge { font-size: 1.08rem; margin-top: 2px; }
  .game-header .lesson-progress-track { width: 100%; height: 4px; margin-top: 7px; }
  .header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-left: 20px; border-left: 1px solid #dce5ef; }
  .header-actions .btn { min-height: 38px; padding: 8px 12px; font-size: .8rem; white-space: nowrap; border-radius: 10px; }
  .header-actions #btn-home-icon { color: #52657c; background: transparent; border-color: #dce5ef; }
  body:not(.has-projector) #btn-single-display { display: none; }
  body.has-projector #btn-open-projector { display: none; }
  #btn-single-display { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
  .projector-view .game-header { grid-template-columns: minmax(0, 1fr) auto; }
  .projector-view .header-actions { display: none; }
  .projector-view .game-header .brand-title { font-size: clamp(24px, 2vw, 36px); }
  .projector-view .game-header .stat-value { font-size: clamp(24px, 2vw, 34px); }
  .projector-view .game-header .stat-value.badge { font-size: clamp(21px, 1.8vw, 30px); }
}
@media screen and (max-width: 1150px) {
  body:not(.projector-view) .game-header { grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
  .header-actions { grid-column: 1 / -1; border-left: 0; border-top: 1px solid #e5edf5; padding: 10px 0 0; }
}
@media screen and (max-width: 600px) {
  .game-header { padding: 14px; }
  .game-header .brand-title { font-size: 1.2rem; }
  .game-header .header-stats { gap: 10px; }
  .game-header .stat-box { min-width: 0; padding: 0; }
  .game-header .lesson-progress-box { min-width: 0; padding-left: 10px; }
  .game-header .stat-value { font-size: 1.1rem; }
  .game-header .stat-value.badge { font-size: .86rem; }
  .header-actions { justify-content: flex-start; flex-wrap: wrap; }
}
@media print { .header-actions { display: none !important; } }
