:root {
  --paper: #fffdf5;
  --ink: #173042;
  --muted: #557080;
  --line: #d9e4df;
  --green: #8bc53f;
  --blue: #2d6cdf;
  --orange: #f3a833;
  --rose: #e85d75;
  --panel: #ffffff;
  --shadow: 0 18px 45px rgba(23, 48, 66, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(139, 197, 63, 0.18), transparent 38%),
    linear-gradient(180deg, #e9f6ff 0%, var(--paper) 54%, #fff4dd 100%);
}

button,
input {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 30px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

.score-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.score-strip span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 800;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.menu-section {
  display: block;
}

.menu-tile {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
  padding: 18px;
  text-align: left;
}

.menu-tile strong {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.menu-tile span {
  color: var(--muted);
  font-weight: 800;
}

.menu-tile.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tab,
.tool-button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 800;
}

.tab {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
}

.tab.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 9px 24px rgba(45, 108, 223, 0.24);
}

[hidden] {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.map-panel,
.activity-panel,
.study-list {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(217, 228, 223, 0.9);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.map-panel {
  padding: 10px;
}

.map-tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.tool-button {
  background: #eef7f2;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0 13px;
}

.map-frame {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #dbeeb8;
  aspect-ratio: 830 / 483;
  margin: 0 auto;
}

.map-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.markers {
  position: absolute;
  inset: 0;
}

.marker {
  position: absolute;
  width: 4.2%;
  max-width: 34px;
  min-width: 24px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--rose);
  box-shadow: 0 3px 0 rgba(23, 48, 66, 0.18), 0 0 0 3px rgba(232, 93, 117, 0.3);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(0.7rem, 1.5vw, 0.95rem);
}

.marker.landmark {
  background: var(--orange);
  box-shadow: 0 3px 0 rgba(23, 48, 66, 0.18), 0 0 0 3px rgba(243, 168, 51, 0.3);
}

.marker.is-target {
  outline: 5px solid rgba(45, 108, 223, 0.35);
}

.marker.is-correct {
  background: #1f9d55;
}

.marker.is-wrong {
  background: #d72f47;
}

.answer-label {
  position: absolute;
  transform: translate(0, -50%);
  max-width: 34%;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--blue);
  font-size: clamp(0.72rem, 1.7vw, 1rem);
  font-weight: 900;
  line-height: 1.1;
  pointer-events: none;
  text-shadow: 0 1px 0 #fff;
}

.activity-panel {
  padding: 18px;
  min-height: 430px;
}

.english-workspace {
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.8fr);
}

.word-board {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(217, 228, 223, 0.9);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 16px;
}

.word-board h2 {
  margin-bottom: 12px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.word-card {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 10px;
  text-align: left;
}

.word-card strong,
.word-card span {
  display: block;
}

.word-card strong {
  font-size: 1.05rem;
}

.word-card span {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.progress-line {
  height: 9px;
  border-radius: 999px;
  background: #e6eee9;
  overflow: hidden;
  margin-bottom: 18px;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--orange));
  transition: width 180ms ease;
}

.mode-label {
  margin-bottom: 7px;
  color: var(--rose);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.activity-panel h2 {
  margin-bottom: 16px;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.1;
}

.answer-area {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.choice-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 10px 12px;
  font-weight: 800;
}

.choice-button small,
.place-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.choice-name {
  display: block;
}

.choice-button.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px rgba(45, 108, 223, 0.18);
}

.spell-input {
  width: 100%;
  min-height: 50px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
}

.feedback {
  min-height: 52px;
  color: var(--muted);
  line-height: 1.35;
}

.round-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  background: #fff4df;
  color: #5a3a00;
  border: 1px solid #f0cd89;
}

.study-list,
.exam-history {
  margin-top: 16px;
  padding: 16px;
}

.study-list h2,
.exam-history h2 {
  margin-bottom: 12px;
}

.place-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.place-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  min-height: 48px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
}

.place-chip strong {
  display: block;
}

.place-chip span {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #edf5ff;
  color: var(--blue);
  font-size: 0.82rem;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.history-item {
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.history-item strong {
  display: block;
  font-size: 1.25rem;
}

.history-item span,
.history-item small {
  color: var(--muted);
  font-weight: 800;
}

.history-item small {
  display: block;
  margin-top: 2px;
}

.wide-action {
  width: 100%;
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    display: block;
  }

  .score-strip {
    justify-content: start;
    margin-top: 12px;
  }

  .activity-panel {
    margin-top: 14px;
    min-height: auto;
  }

  .place-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  .menu-grid,
  .mode-tabs,
  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-tile {
    min-height: 118px;
  }

  .map-tools,
  .round-actions {
    grid-template-columns: 1fr;
  }

  .map-tools {
    display: grid;
  }

  .place-grid,
  .word-grid {
    grid-template-columns: 1fr;
  }
}
