:root {
  --qj-cyan: #0ea5e9;
  --qj-blue: #2563eb;
  --qj-dark: #0f172a;
  --qj-amber: #f59e0b;
  --qj-coral: #ef4444;
  --qj-paper: #fffaf0;
  --ink: #19312b;
  --shadow: 0 22px 70px rgba(9, 30, 25, 0.26);
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 32px 32px,
    #11473d;
  overflow: hidden;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7, var(--qj-blue));
  color: white;
  padding: 6px 16px;
  border-radius: 30px;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

.brand-logo-icon {
  font-size: 20px;
}

.brand-name {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 1px;
}

.brand-sub {
  font-size: 13px;
  opacity: 0.85;
}

.admin-hotspot {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 18;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--qj-paper);
  box-shadow: 5px 5px 0 rgba(25, 49, 43, 0.22);
  transition: transform 0.2s;
}

.admin-hotspot:hover {
  transform: rotate(45deg);
  background: var(--qj-amber);
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 72px;
  padding: 10px clamp(18px, 3vw, 42px);
  background: rgba(247, 255, 246, 0.96);
  border-bottom: 5px solid var(--qj-cyan);
  box-shadow: 0 8px 24px rgba(11, 36, 32, 0.18);
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: clamp(16px, 1.5vw, 22px);
  font-weight: 800;
}

.progress-copy strong {
  color: var(--qj-blue);
  font-size: 1.18em;
}

.progress-track {
  height: clamp(20px, 2vw, 28px);
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #dce8df, #bed0c6);
  border: 3px solid var(--ink);
  border-radius: 8px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--qj-cyan), var(--qj-blue), var(--qj-amber));
  transition: width 420ms ease;
}

.progress-fill.charged {
  animation: energyPulse 1s infinite alternate;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.mode-button {
  min-height: 44px;
  padding: 6px 14px;
  color: var(--ink);
  font-weight: 900;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: 4px 4px 0 rgba(25, 49, 43, 0.18);
}

.mode-button.active {
  color: white;
  background: #17634f;
}

.icon-button {
  padding: 6px 12px;
  font-size: 22px;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: clamp(16px, 2.4vw, 34px);
  height: calc(100vh - 72px);
  padding: clamp(10px, 1.8vw, 28px);
}

.picture-zone, .answer-zone {
  border: 4px solid rgba(247, 255, 246, 0.82);
  border-radius: 8px;
  background: var(--qj-paper);
  box-shadow: var(--shadow);
}

.picture-zone {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: clamp(10px, 1.4vw, 18px);
}

.image-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  margin: 0;
}

.image-stage img {
  align-self: center;
  justify-self: center;
  width: 100%;
  height: min(64vh, 700px);
  object-fit: contain;
  border: 5px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: 12px 12px 0 var(--qj-amber);
}

.image-stage figcaption, .status-line {
  display: none;
}

.answer-zone {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
  gap: 12px;
  padding: clamp(14px, 2vw, 24px);
  background: #f5fff8;
}

.score-board div {
  display: grid;
  place-items: center;
  min-height: 58px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: white;
}

.score-board span {
  font-size: clamp(16px, 1.5vw, 22px);
  font-weight: 800;
}

.score-board strong {
  color: var(--qj-blue);
  font-size: clamp(28px, 3.4vw, 46px);
  line-height: 0.95;
}

.choice-hint {
  min-height: 52px;
  display: grid;
  place-items: center;
  color: var(--qj-coral);
  font-size: clamp(20px, 2.8vw, 36px);
  font-weight: 900;
  border: 3px solid var(--qj-coral);
  border-radius: 8px;
  background: #fff5dc;
  padding: 8px;
  text-align: center;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  gap: 16px;
}

.option-button {
  min-height: clamp(68px, 8.5vh, 94px);
  padding: 8px 16px;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: 8px 8px 0 rgba(25, 49, 43, 0.18);
  transition: transform 140ms, box-shadow 140ms;
}

.option-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 rgba(25, 49, 43, 0.22);
}

.option-button.correct {
  color: white;
  background: #17634f;
}

.option-button.wrong {
  color: white;
  background: var(--qj-coral);
}

.action-row {
  display: grid;
  grid-template-columns: 0.8fr 1fr 0.9fr;
  gap: 12px;
}

.tool-button {
  min-height: 50px;
  padding: 8px 16px;
  color: var(--ink);
  font-weight: 900;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 5px 5px 0 rgba(25, 49, 43, 0.18);
}

.tool-button.primary {
  color: white;
  background: var(--qj-blue);
}

.tool-button.reward {
  color: var(--ink);
  background: var(--qj-amber);
}

.tool-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.tool-button.wide {
  width: 100%;
  margin-top: 10px;
}

/* 弹窗与控制面板结构修复 */
.reward-modal, .admin-modal, .unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(4, 20, 17, 0.72);
}

.modal-panel, .unlock-card {
  position: relative;
  width: min(96vw, 980px);
  max-height: 90vh;
  overflow-y: auto;
  border: 5px solid var(--ink);
  border-radius: 12px;
  background: var(--qj-paper);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 36px);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 46px;
  height: 46px;
  color: white;
  font-size: 30px;
  line-height: 1;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--qj-coral);
}

.kicker {
  margin: 0;
  color: var(--qj-coral);
  font-weight: 900;
}

h2 {
  margin: 6px 0 18px;
  font-size: clamp(24px, 3vw, 42px);
}

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

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 900;
}

.settings-grid input, .settings-grid select {
  min-height: 48px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
}

.check-line {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
}

.check-line input {
  width: 24px;
  min-height: 24px;
}

.prize-editor {
  margin-top: 24px;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.prize-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 2px solid rgba(25, 49, 43, 0.15);
}

.prize-row input {
  min-height: 42px;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 24px;
}

.form-note {
  margin-top: 12px;
  color: var(--qj-coral);
  font-weight: 900;
}

.scratch-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 280px;
  border: 5px solid var(--ink);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.scratch-card canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.prize-result, .wheel-result {
  color: var(--qj-coral);
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 900;
  text-align: center;
}

.wheel-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: min(50vh, 460px);
  margin: 0 auto;
}

.wheel-wrap canvas {
  width: 100%;
  height: auto;
}

.wheel-pointer {
  position: absolute;
  top: -2px;
  width: 0;
  height: 0;
  border-right: 20px solid transparent;
  border-left: 20px solid transparent;
  border-top: 48px solid var(--qj-coral);
}

/* 田字格增强 */
.writing-zone {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border-top: 4px solid var(--ink);
  padding-top: 10px;
}

.tian-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.tian-cell {
  position: relative;
  aspect-ratio: 1;
  border: 3px solid var(--qj-coral);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(233, 93, 68, 0.35) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(233, 93, 68, 0.35) 50%, transparent 51%),
    #fffef8;
  overflow: hidden;
}

.tian-cell canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.writing-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 34;
  overflow: hidden;
  pointer-events: none;
}

.crying-face {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 35;
  font-size: 140px;
  transform: translate(-50%, -50%);
  animation: cryingPop 1.4s ease forwards;
}

@keyframes energyPulse {
  from { filter: drop-shadow(0 0 2px var(--qj-amber)); }
  to { filter: drop-shadow(0 0 10px var(--qj-amber)); }
}

@keyframes cryingPop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .game-shell { grid-template-columns: 1fr; height: auto; }
  .top-strip { grid-template-columns: 1fr; gap: 10px; }
  .settings-grid, .prize-row, .admin-actions { grid-template-columns: 1fr; }
}