*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #1f2937;
  background: linear-gradient(165deg, #e8f5e9 0%, #f1f8e9 40%, #fff8e1 100%);
  background-attachment: fixed;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* 顶部深绿条：内容与教室同宽、同 padding，保证按钮与黑板左右对齐 */
.header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header-inner {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px;
  min-height: 48px;
}

.btn-header-action {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-header-action.btn-header-blink {
  animation: btn-header-pulse 1.4s ease-in-out infinite;
}

@keyframes btn-header-pulse {
  0%, 100% {
    transform: translateY(-50%) scale(1);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  40% {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45);
  }
}

.btn-back-header {
  left: 16px;
}

.btn-back-header:hover {
  background: rgba(255, 255, 255, 0.35);
}

.btn-join-header {
  right: 16px;
}

.btn-join-header:hover {
  background: rgba(255, 255, 255, 0.35);
}

.header-title {
  margin: 0;
  padding: 0 100px;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 700;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.header-title span + span {
  margin-left: 0.5em;
}

/* 教室主体：上边距缩小，时钟+流动广告更靠近绿色顶栏，黑板随之靠上 */
.classroom {
  flex: 1;
  min-height: 0;
  padding: 2px 16px 16px 16px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 上方：时间 + 班级新闻，与黑板同宽对齐 */
.top-bar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 0;
}

.top-bar-left {
  width: 112px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-how-to-play {
  flex-shrink: 0;
  height: 34px;
  padding: 0 18px;
  border-radius: 10px;
  border: 2px solid rgba(234, 88, 12, 0.4);
  background: linear-gradient(180deg, #fb923c 0%, #f97316 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(249, 115, 22, 0.35);
}

.btn-how-to-play.btn-how-to-play-blink {
  animation: btn-how-to-play-pulse 1.4s ease-in-out infinite;
}

@keyframes btn-how-to-play-pulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 3px 8px rgba(249, 115, 22, 0.35);
  }
  40% {
    transform: translateY(-1px) scale(1.06);
    box-shadow: 0 0 0 4px rgba(248, 250, 252, 0.8), 0 4px 12px rgba(249, 115, 22, 0.6);
  }
}

.btn-how-to-play:hover {
  filter: brightness(1.05);
}

.table-time-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #e8f5e9 100%);
  border: 2px solid rgba(46, 125, 50, 0.3);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.table-time {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
  color: #1b5e20;
}

.class-news-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
}

.class-news {
  flex: 1;
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 0;
  background: linear-gradient(180deg, #fff 0%, #e8f5e9 100%);
  border: 2px solid rgba(46, 125, 50, 0.25);
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.class-news-marquee {
  overflow: hidden;
  width: 100%;
}

.class-news-track {
  display: flex;
  width: max-content;
  animation: class-news-scroll 15s linear infinite;
}

.class-news-text {
  flex-shrink: 0;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  color: #c62828;
  white-space: nowrap;
}

/* 流动广告内人名、外号、活动词均为蓝色 */
.class-news-marquee .class-news-text .class-news-name,
.class-news-track .class-news-text .class-news-name {
  color: #2563eb !important;
  font-weight: 600;
}

/* 活动名字（如心里话与心中歌、递纸条、取外号为）为蓝色 */
.class-news-marquee .class-news-text .class-news-heart-label,
.class-news-marquee .class-news-text .class-news-activity,
.class-news-track .class-news-text .class-news-heart-label,
.class-news-track .class-news-text .class-news-activity {
  color: #2563eb !important;
  font-weight: 600;
}

/* 同学名字（取外号 A B C D）为蓝色 */
.class-news-marquee .class-news-text .class-news-nickname-name,
.class-news-track .class-news-text .class-news-nickname-name {
  color: #2563eb !important;
  font-weight: 600;
}

/* 其他文案为红色 */
.class-news-marquee .class-news-text .class-news-nickname-other {
  color: #c62828 !important;
  font-weight: 600;
}

@keyframes class-news-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* 黑板 + 左侧按钮：贴近上方流动广告，整行等高、黑板下端与按钮3下端对齐 */
.blackboard-wrap {
  margin-top: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.blackboard-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-height: calc(168px + 4vw);
}

.blackboard-footer-row {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 4px;
  width: 100%;
}

.blackboard-footer {
  position: absolute;
  right: 0;
  top: 0;
  margin-top: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.blackboard-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 112px;
  flex-shrink: 0;
  min-height: calc(168px + 4vw);
}

.btn-side {
  flex: 1;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  background: #f5f5f5;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-side.is-alert {
  animation: msg-blink 1.6s ease-in-out infinite;
}

/* 消息：气泡形 logo */
.btn-side-msg {
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 4px;
  position: relative;
}
.btn-side-msg::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #f5f5f5;
  border-left-width: 5px;
  border-right-width: 5px;
}
.btn-side-msg-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #4b5563;
}
.btn-side-msg-icon svg {
  width: 100%;
  height: 100%;
}
.btn-side-msg-text {
  font-size: 12px;
  line-height: 1;
}
.btn-side-msg:hover {
  background: #ebebeb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.btn-side-msg:hover::after {
  border-top-color: #ebebeb;
}

/* 我的书包：背包形 logo */
.btn-side-bag {
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px 10px 16px 16px;
  border: 1px solid #d1d5db;
}
.btn-side-bag-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #4b5563;
}
.btn-side-bag-icon svg {
  width: 100%;
  height: 100%;
}
.btn-side-bag-text {
  font-size: 12px;
  line-height: 1;
}
.btn-side-bag:hover {
  background: #ebebeb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-coins-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  margin-top: 4px;
}

.btn-side-coins {
  flex: 0 0 auto;
  width: 96px;
  height: 48px;
  min-width: 96px;
  min-height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #dc2626 0%, #ef4444 40%, #f87171 100%);
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-side-coins:hover,
.btn-side-coins:focus,
.btn-side-coins:active {
  background: linear-gradient(180deg, #dc2626 0%, #ef4444 40%, #f87171 100%);
  filter: none;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-side-coins.coins-blink {
  animation: coins-blink 0.6s ease-out;
}

@keyframes coins-blink {
  0%, 100% { filter: brightness(1); box-shadow: 0 3px 10px rgba(220, 38, 38, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
  50% { filter: brightness(1.35); box-shadow: 0 0 16px rgba(220, 38, 38, 0.7), 0 3px 10px rgba(220, 38, 38, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
}

.btn-coins-num {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  line-height: 1;
}

.btn-coins-label {
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  line-height: 1.2;
}

@keyframes msg-blink {
  0%, 70%, 100% {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    background: #f5f5f5;
  }
  35% {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.35), 0 6px 14px rgba(0, 0, 0, 0.18);
    background: #fff7ed;
  }
}

.btn-side:hover {
  background: #eee;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.blackboard-inner {
  flex: 1;
  min-width: 0;
  margin-left: 2px;
  display: flex;
}

.blackboard {
  flex: 1;
  padding: 28px 16px;
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  background: linear-gradient(180deg, #37474f 0%, #263238 50%, #1a252b 100%);
  border-radius: 12px;
  border: 3px solid #5d4e37;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  min-height: calc(168px + 4vw);
  display: flex;
  align-items: center;
  justify-content: center;
}

.blackboard.blackboard-guide {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  text-align: center;
}

.blackboard .blackboard-guide-title {
  width: 100%;
  text-align: center;
  font-weight: 900;
  color: #ff3b3b;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  font-size: clamp(18px, 4.2vw, 24px);
  line-height: 1.25;
  margin-top: 6px;
}

.blackboard .blackboard-guide-lines {
  width: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.96);
  font-weight: 700;
  font-size: clamp(14px, 3.6vw, 18px);
  line-height: 1.55;
  padding: 0 6px;
}

.blackboard .blackboard-guide-lines div + div {
  margin-top: 6px;
}

.blackboard.blackboard-has-knowledge {
  white-space: pre-wrap;
  text-align: left;
  overflow-y: auto;
  font-size: 14px;
  font-weight: 500;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
}

.blackboard .blackboard-title {
  width: 100%;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.98);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.blackboard .blackboard-body {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  white-space: pre-wrap;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}

/* 老师：与座位中线对齐，图像 + 下方名字 */
.teacher-wrap {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  min-height: 72px;
}

.teacher {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  min-width: 88px;
  min-height: 72px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.teacher .teacher-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #f0f0f0;
  display: block;
  flex-shrink: 0;
}

.teacher .teacher-label {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  max-width: 120px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 学生座位：每行 4 对同桌 + 3 条过道，第1列靠左、第8列靠右墙 */
.seats-section {
  margin-bottom: 3px;
}

.seats-grid {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.seats-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  width: 100%;
}

.seat-pair {
  flex: 1;
  min-width: 0;
  max-width: 168px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* 第2列与第3列、第4列与第5列、第6列与第7列之间的过道 */
.seat-aisle {
  flex: 0 0 4px;
  min-width: 4px;
  max-width: 4px;
  background: transparent;
  pointer-events: none;
}

.seat {
  width: 100%;
  aspect-ratio: 1;
  max-width: 84px;
  min-height: 0;
  padding: 6px;
  background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  transition: transform 0.2s, box-shadow 0.2s;
}

/* 同桌之间无缝隙：同一 pair 内左边座位去掉右边圆角与右边距 */
.seat-pair .seat:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right-width: 1px;
}

.seat-pair .seat:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 1px;
}

.seat:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.seat.seat-empty {
  color: #9ca3af;
}

/* 底部动作区：并排 8 个，2 行，平均分布、左右靠边，大小与桌子相近 */
.bottom-bar {
  padding-top: 2px;
  border-top: 1px solid #2563eb;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto auto;
  gap: 8px 2px;
  width: 100%;
  align-items: stretch;
  justify-items: stretch;
}

.action-cell {
  width: 100%;
  min-height: 58px;
  height: 72px;
  max-height: 96px;
  padding: 4px 3px;
  font-size: 11px;
  font-weight: 600;
  color: #1b5e20;
  background: linear-gradient(180deg, #fff 0%, #e8f5e9 100%);
  border: 1px solid rgba(46, 125, 50, 0.3);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  box-sizing: border-box;
}

.action-cell-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #1b5e20;
}
.action-cell-icon svg {
  width: 100%;
  height: 100%;
}
.action-cell-text {
  line-height: 1.2;
  word-break: break-all;
  font-size: 11px;
  font-weight: 600;
}

.action-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.action-cell:disabled,
.action-cell.pass-note-disabled {
  color: #9ca3af;
  background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
  border-color: #d1d5db;
  cursor: not-allowed;
  box-shadow: none;
}

.action-cell:disabled:hover,
.action-cell.pass-note-disabled:hover {
  transform: none;
  box-shadow: none;
}

.action-cell-love-letter {
  color: #1b5e20;
  background: linear-gradient(180deg, #fff 0%, #fef7f9 50%, #fdf2f6 100%);
  border-color: rgba(46, 125, 50, 0.28);
}
.action-cell-love-letter .action-cell-icon { color: #1b5e20; }
.action-cell-love-letter:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.action-cell.pass-note-blink,
.action-cell-i-remember.pass-note-blink {
  animation: pass-note-blink 0.6s ease-in-out infinite;
}
.action-cell-love-letter.pass-note-blink {
  animation: pass-note-blink-love 0.6s ease-in-out infinite;
}

@keyframes pass-note-blink {
  0%, 100% {
    background: linear-gradient(180deg, #fff 0%, #e8f5e9 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border-color: rgba(46, 125, 50, 0.3);
  }
  50% {
    background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.9), 0 0 40px rgba(251, 146, 60, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: #f97316;
  }
}

@keyframes pass-note-blink-love {
  0%, 100% {
    background: linear-gradient(180deg, #fff 0%, #fef7f9 50%, #fdf2f6 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border-color: rgba(46, 125, 50, 0.28);
  }
  50% {
    background: linear-gradient(180deg, #fef7f9 0%, #fdf2f6 100%);
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: rgba(190, 24, 93, 0.25);
  }
}

/* 响应式：手机 */
@media (max-width: 480px) {
  .header-inner {
    min-height: 42px;
    padding: 6px 8px;
  }
  .btn-back-header {
    padding: 6px 10px;
    font-size: 14px;
    left: 8px;
  }
  .btn-join-header {
    padding: 6px 10px;
    font-size: 14px;
    right: 8px;
  }
  .header-title {
    font-size: 12px;
    padding-left: 100px;
    padding-right: 70px;
  }
  .classroom {
    padding: 2px 8px 10px 8px;
  }
  .top-bar-left {
    width: 120px;
  }
  .table-time-wrap {
    min-width: 68px;
    height: 30px;
  }
  .class-news {
    min-height: 30px;
  }
  .table-time { font-size: 13px; }
  .btn-how-to-play {
    height: 36px;
    padding: 0 14px;
    font-size: 14px;
    border-radius: 12px;
  }
  .blackboard {
    min-height: calc(172px + 4vw);
    font-size: 16px;
  }
  .blackboard-wrap {
    margin-bottom: 0;
  }
  .blackboard-row {
    min-height: calc(172px + 4vw);
  }
  .blackboard-inner {
    margin-left: 2px;
  }
  .blackboard-side {
    width: 120px;
    min-height: calc(172px + 4vw);
  }
  .btn-side {
    padding: 14px 16px;
    font-size: 14px;
  }
  .seats-grid {
    gap: 2px;
  }
  .seat-aisle {
    flex: 0 0 3px;
    min-width: 3px;
    max-width: 3px;
  }
  .seat-pair {
    max-width: 96px;
  }
  .seat {
    max-width: 48px;
    padding: 4px;
    font-size: 11px;
  }
  .action-cell {
    min-height: 40px;
    height: 52px;
    font-size: 10px;
  }
  .action-cell .action-cell-text {
    font-size: 10px;
  }
}
