html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--color-page-bg);
  color: var(--color-page-text);
  min-height: 100vh;
  min-height: 100dvh;
}

.game-wrapper {
  height: calc(100vh - var(--header-height, 70px));
  height: calc(100dvh - var(--header-height, 70px));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  box-sizing: border-box;
}

/* Compact board */
.game-board {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 800px;
  padding: 16px;
  padding-bottom: 95px;
  box-sizing: border-box;
  background: var(--color-surface-1, var(--color-grid-area-bg));
  border-radius: 18px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);

  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
}

/* Level indicators — clickable */
#levelIndicators {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.level-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-header-border, #666);
  color: var(--color-page-text);
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: all 0.2s ease;
  cursor: pointer;
}

.level-dot:hover {
  transform: scale(1.4);
  opacity: 1;
}

.level-dot.current {
  background: var(--color-accent-blue, #4285F4);
  color: white;
  opacity: 1;
  transform: scale(1.3);
}

.level-dot.completed {
  background: var(--color-ok, #34A853);
  color: white;
  opacity: 0.8;
}

/* Main hanzi panel */
#hanziPanel {
  height: 175px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--color-surface-2, var(--color-cell-bg));
  border: 3px solid var(--color-accent-blue, #4285F4);
  border-radius: 16px;
}

#hanziSymbol {
  font-size: 110px;
  font-weight: 900;
  color: var(--color-page-text);
  user-select: none;
}

/* Answer grid */
#answerPanel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  height: 195px;
}

.hanzi-option-btn {
  font-size: 35px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--color-cell-bg);
  color: var(--color-cell-text);
  border: 2px solid var(--color-header-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.hanzi-option-btn:hover:not(:disabled) {
  background: var(--color-cell-hover-bg);
  color: var(--color-cell-hover-text);
  transform: translateY(-4px);
}

.hanzi-option-btn.correct {
  background: var(--color-ok, #34A853);
  color: white;
}

.hanzi-option-btn.wrong {
  background: var(--color-bad, #EA4335);
  color: white;
}

/* Feedback — optimized for long text */
.feedback {
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  min-height: 110px;
  max-height: 150px;
  padding-top: 0px;
  color: var(--color-page-text);
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  word-break: break-word;
}

.feedback.correct { color: var(--color-ok, #34A853); }
.feedback.wrong { color: var(--color-bad, #EA4335); }

/* Button container */
#buttonContainer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}

#buttonContainer button {
  padding: 9px 20px;
  font-size: 17px;
  font-weight: bold;
  background: var(--color-accent-blue, #4285F4);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 130px;
  min-height: 48px;
}

#buttonContainer button:hover:not(:disabled) {
  background: var(--color-accent-green, #34A853);
  transform: translateY(-2px);
}

#nextLevelBtn {
  background: var(--color-ok, #34A853);
}

.hidden {
  display: none !important;
}

/* MODALS — identical to memory.css */
.stats-modal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 9999;
}

.stats-modal.open {
  display: flex;
}

.stats-modal-content {
  background: #ffffff;
  color: #111;
  padding: 24px 28px;
  border-radius: 10px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.4);
}

.stats-modal-content h2 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  color: #16a34a;
}

.stats-list {
  text-align: left;
  margin: 16px 0 22px 0;
  font-size: 1rem;
  line-height: 1.6;
}

.stats-buttons {
  display: grid;
  gap: 10px;
}

.stats-btn {
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.stats-btn.finish { background: #444; color: #fff; }
.stats-btn.new-game { background: #3b82f6; color: #fff; }
.stats-btn.change-level { background: #e67e22; color: #fff; }
.stats-btn.save-results { background: #16a34a; color: #fff; }

/* Mobile optimizations */
@media (max-width: 600px) {
  .game-board {
    max-width: 96%;
    padding: 12px;
    padding-bottom: 85px;
    gap: 10px;
  }
  #hanziPanel {
    height: 160px;
  }
  #hanziSymbol {
    font-size: 88px;
  }
  #answerPanel {
    height: 180px;
    gap: 8px;
  }
  .hanzi-option-btn {
    font-size: 34px;
  }
  .feedback {
    font-size: 20px;
    min-height: 100px;
    max-height: 130px;
    padding: 10px;
    line-height: 1.4;
  }
  #buttonContainer {
    bottom: 14px;
    left: 12px;
    right: 12px;
  }
  #buttonContainer button {
    font-size: 16px;
    padding: 8px 18px;
    min-width: 120px;
    min-height: 46px;
  }
}

/* Safe-area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .game-board {
    padding-bottom: max(95px, calc(85px + env(safe-area-inset-bottom)));
  }
}