/* 游戏界面样式
 *
 * 重点考虑：手机上单手操作、方块要够大（≥64px）、投影/大屏自动放大、
 * 长单词自动缩小字号而不是溢出。 */

.hero { text-align: center; padding: .5rem 0; }
.hero h1 { font-size: 1.5rem; margin-bottom: .2rem; }

.class-info {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem; margin-bottom: 1rem;
}
.class-info .title { font-size: 1.1rem; font-weight: 600; }

.code-input {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.5rem; letter-spacing: .2em; text-align: center;
  text-transform: uppercase;
}

.big-ready { font-size: 3rem; text-align: center; margin: .25rem 0; }
.student-card { text-align: center; }
.student-card .name { font-size: 1.3rem; font-weight: 600; }

/* ---------------- 模式选择 ---------------- */

.mode-picker { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; text-align: left; }

.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  background: var(--bg-soft); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: .85rem 1rem;
  color: var(--text); text-align: left; cursor: pointer;
  min-height: 68px;
}
.mode-btn:hover:not(:disabled) { border-color: var(--primary); filter: none; }
.mode-btn .mode-icon { font-size: 1.3rem; }
.mode-btn .mode-name { font-weight: 600; font-size: 1.05rem; }
.mode-btn .mode-desc { font-size: .82rem; color: var(--text-dim); }

/* ---------------- 顶部信息条 ---------------- */

.hud {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: .4rem; padding: .6rem .75rem .35rem;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.hud-item { text-align: center; }
.hud-label { display: block; font-size: .7rem; color: var(--text-dim); }
.hud-value {
  display: block; font-size: 1.3rem; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.hud-value.combo { color: var(--warn); }

.timebar-track { height: 5px; background: var(--bg-soft); }
.timebar {
  height: 100%; background: var(--primary); width: 100%;
  transition: width .2s linear, background .2s;
}
.timebar.urgent { background: var(--danger); }

/* ---------------- 棋盘 ---------------- */

.board-wrap { padding: .75rem; }

.board {
  display: grid;
  /* 列数由 JS 按方块数设置 */
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: .5rem;
  max-width: 720px;
  margin: 0 auto;
}

.tile {
  /* 关键：正方形方块，且足够大以便点按 */
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  padding: .25rem;
  border-radius: 10px;
  border: 2px solid transparent;
  font-family: inherit;
  font-size: clamp(.9rem, 3.6vw, 1.35rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  word-break: break-word;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 0;
  transition: transform .12s, background .12s, opacity .25s, border-color .12s;
}

/* 英文块与中文块用不同色系区分，方便学生一眼分辨该点哪一类 */
.tile-en { background: #1e3a5f; color: #bae6fd; }
.tile-zh { background: #3f2d5c; color: #e9d5ff; }

/* 长词自动缩字号，避免溢出 */
.tile.long { font-size: clamp(.78rem, 3vw, 1.1rem); }
.tile.xlong { font-size: clamp(.68rem, 2.5vw, .95rem); }

.tile:hover:not(.matched):not(.gone) { transform: translateY(-2px); }

.tile.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .35);
  transform: translateY(-2px);
}

.tile.wrong {
  border-color: var(--danger);
  background: #7f1d1d !important;
  animation: shake .32s;
}

.tile.reveal { border-color: var(--warn); }

.tile.matched {
  border-color: var(--success);
  background: #065f46 !important;
  animation: pop .32s;
}

.tile.gone { opacity: 0; transform: scale(.7); pointer-events: none; }

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.play-footer {
  padding: .5rem .75rem 1.25rem;
  display: flex; justify-content: center;
}

/* ---------------- 结算 ---------------- */

.result-head { text-align: center; }
.result-emoji { font-size: 3rem; line-height: 1; }

.score-big { text-align: center; margin: .5rem 0 .2rem; }
.score-num {
  font-size: 3.4rem; font-weight: 800; color: var(--primary);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.score-unit { font-size: 1.1rem; color: var(--text-dim); margin-left: .2rem; }

/* ---------------- 排行榜 ---------------- */

.tab-scope.active {
  background: var(--primary-dark); color: #fff; border-color: transparent;
}

tr.is-me { background: rgba(56, 189, 248, .14); }
tr.is-me td { font-weight: 600; }

.medal { font-size: 1.05rem; }

/* ---------------- 大屏（投影）自动放大 ---------------- */

@media (min-width: 900px) {
  .board { max-width: 900px; gap: .75rem; }
  .tile { font-size: clamp(1.1rem, 2vw, 1.7rem); }
  .tile.long { font-size: clamp(1rem, 1.7vw, 1.4rem); }
  .tile.xlong { font-size: clamp(.9rem, 1.4vw, 1.2rem); }
  .hud-value { font-size: 1.6rem; }
}
