:root {
  --blue: #3aa7ff;
  --blue-dark: #1672c7;
  --yellow: #ffd84d;
  --green: #55d987;
  --red: #ff6f6f;
  --ink: #17324d;
  --muted: #60758d;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 18px 50px rgba(35, 93, 143, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 12%, #fff6b8 0 7%, transparent 8%),
    linear-gradient(180deg, #bdeaff 0%, #e9fbff 52%, #c7f2d0 100%);
  overflow-x: hidden;
}

.typing-site-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 12px 5vw;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(30, 136, 229, 0.15);
  backdrop-filter: blur(14px);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.brand-link img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 14px;
  background: white;
}

.typing-site-header nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #eef8ff;
  text-decoration: none;
  box-shadow: none;
}

button, input, textarea, select { font: inherit; }

button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

button:hover { transform: translateY(-2px) scale(1.02); }
button:active { transform: scale(0.98); }

.primary {
  padding: 12px 20px;
  color: #15334f;
  background: linear-gradient(180deg, #ffe777, #ffc83d);
  box-shadow: 0 8px 0 #e4a928, 0 16px 28px rgba(189, 132, 17, 0.2);
}

.secondary {
  padding: 12px 20px;
  color: white;
  background: linear-gradient(180deg, #52b8ff, #2187df);
  box-shadow: 0 8px 0 #1269b7, 0 16px 28px rgba(23, 114, 199, 0.18);
}

.ghost {
  padding: 12px 20px;
  color: var(--blue-dark);
  background: white;
  box-shadow: inset 0 0 0 2px #b7e3ff;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.danger {
  padding: 10px 16px;
  color: white;
  background: var(--red);
}

.big { min-width: 170px; font-size: 18px; }

.app {
  position: relative;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 52px;
  z-index: 1;
}

.page {
  display: none;
  animation: fadeIn 0.28s ease;
}

.page.active { display: block; }

.home-page {
  min-height: calc(100vh - 84px);
  align-items: center;
  gap: 28px;
}

.home-page.active {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
}

.hero, .island-card, .typing-card, .guide-panel, .form-card, .filter-panel, .modal-card, .chapter-card, .empty-card {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero { padding: clamp(28px, 5vw, 58px); }

.kicker {
  display: inline-block;
  margin: 0 0 12px;
  padding: 7px 14px;
  border-radius: 999px;
  color: #0f6a4a;
  background: #d9ffe8;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 86px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2, h3, h4 { margin: 0; letter-spacing: 0; }

.hero h2 {
  margin-top: 10px;
  color: var(--blue-dark);
  font-size: clamp(24px, 4vw, 38px);
}

.intro {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 26px;
}

.island-card {
  min-height: 330px;
  padding: 30px;
  text-align: center;
  align-self: center;
}

.treasure {
  font-size: 90px;
  animation: float 2.2s ease-in-out infinite;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.icon-btn {
  width: 48px;
  height: 48px;
  color: var(--blue-dark);
  background: white;
  box-shadow: var(--shadow);
  font-size: 22px;
}

.filter-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.8fr;
  gap: 18px;
  padding: 18px;
  margin-bottom: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.chip {
  padding: 9px 14px;
  background: #eef8ff;
  color: var(--blue-dark);
  box-shadow: none;
}

.chip.active {
  background: var(--yellow);
  color: #4e3b00;
}

.chapter-map {
  display: grid;
  gap: 20px;
}

.chapter-card {
  padding: 20px;
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.chapter-head h3 {
  font-size: 28px;
}

.chapter-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.chapter-head strong {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  background: #e6ffef;
  color: #136a43;
}

.chapter-tag {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: #fff6cc;
  color: #775900;
  font-weight: 800;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.level-card {
  position: relative;
  min-height: 210px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 26px rgba(35, 93, 143, 0.12);
  border: 2px solid white;
  text-align: left;
}

.level-card h4 {
  padding-right: 44px;
  font-size: 20px;
  margin-bottom: 8px;
}

.level-card p {
  margin: 6px 0;
  color: var(--muted);
}

.level-num {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--yellow);
  color: #5a4300;
  font-weight: 900;
}

.best {
  margin-top: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #fff8d9;
  color: #785800;
  font-weight: 800;
}

.empty-card {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.typing-software {
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, #dff2ff 0%, #f7fcff 48%, #e8f7ff 100%);
  border: 2px solid rgba(255,255,255,0.95);
  box-shadow: var(--shadow);
}

.training-head {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 180px;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.training-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.82);
  border: 1px solid #cfefff;
}

.training-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.training-brand strong,
.training-brand span {
  display: block;
}

.training-brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.training-current {
  min-height: 74px;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  border: 2px solid #b7e3ff;
  text-align: center;
}

.training-current span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.training-current strong {
  display: block;
  color: var(--blue-dark);
  font-size: 34px;
  line-height: 1.2;
}

.sequence-panel {
  margin-bottom: 14px;
  padding: 12px 16px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #cfefff;
}

.sequence-panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 900;
}

.typing-card, .guide-panel, .mini-course-list { padding: 22px; }

.mini-course-list {
  background: rgba(255,255,255,0.92);
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 28px;
  box-shadow: var(--shadow);
  align-self: start;
}

.mini-course-list h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.mini-course-list button {
  width: 100%;
  padding: 10px 12px;
  margin: 5px 0;
  border-radius: 12px;
  background: #eef8ff;
  color: var(--blue-dark);
  text-align: left;
  box-shadow: none;
}

.mini-course-list button.active {
  background: var(--yellow);
  color: #5a4300;
}

.stats, .summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.stats div, .summary-grid div {
  padding: 14px 10px;
  border-radius: 18px;
  background: #eef8ff;
  text-align: center;
}

.stats span, .summary-grid strong {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

.stats small, .summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.target-text {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fbff, #eaf5ff);
  border: 2px solid #b8dcff;
  font-size: 34px;
  line-height: 1.2;
  word-break: break-word;
}

.target-text span {
  min-width: 46px;
  height: 52px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #d7e8f7;
  box-shadow: 0 5px 0 #c8d7e5;
  font-weight: 900;
}

.target-text .ok { color: white; background: #41c978; border-color: #2dab62; box-shadow: 0 5px 0 #239451; }
.target-text .bad { color: white; background: #ff7070; border-color: #df5353; box-shadow: 0 5px 0 #c84040; }
.target-text .next { color: white; background: #22a9ff; border-color: #0d83d1; box-shadow: 0 5px 0 #0a6fb2, 0 0 20px rgba(34,169,255,.45); }

.typing-input {
  width: 100%;
  resize: vertical;
  border: 3px solid #b7e3ff;
  border-radius: 18px;
  padding: 16px;
  font-size: 24px;
  outline: none;
}

.input-capture {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.typing-input:focus { border-color: var(--blue); }
.typing-input.shake { animation: shake 0.22s ease; }

.encourage {
  min-height: 30px;
  color: var(--blue-dark);
  font-weight: 900;
}

.typing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mode-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.82);
  border: 1px solid #cfefff;
}

.mode-row label {
  margin: 0;
}

.finger-hint {
  min-height: 54px;
  padding: 13px;
  border-radius: 18px;
  background: #ffffff;
  color: var(--blue-dark);
  border: 2px solid #b7e3ff;
  font-weight: 900;
  line-height: 1.5;
  text-align: center;
}

.hand-zone {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.hand-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 0;
}

.hand {
  min-height: 178px;
  padding: 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff6df, #fff);
  border: 2px solid #ffdf9d;
}

.hand strong {
  display: block;
  text-align: center;
  margin-bottom: 8px;
}

.fingers {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5px;
  min-height: 118px;
}

.finger {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 88px;
  padding: 5px 3px;
  border-radius: 999px 999px 12px 12px;
  background: #fffaf0;
  border: 2px solid #ffd58d;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  writing-mode: vertical-rl;
}

.finger:nth-child(2), .finger:nth-child(4) { min-height: 82px; }
.finger:nth-child(3) { min-height: 106px; }
.finger:nth-child(5) { min-height: 48px; transform: translateY(20px); }

.finger.active {
  color: #4e3b00;
  background: var(--yellow);
  border-color: #ffbf2f;
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 8px 18px rgba(255, 198, 48, 0.35);
}

.finger:nth-child(5).active {
  transform: translateY(10px) scale(1.05);
}

.keyboard {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #bde4ff, #e8f5ff);
  box-shadow: inset 0 0 0 2px #d8f1ff;
}

.full-keyboard {
  margin-top: 0;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255,255,255,0.9);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 9px 0;
}

.key {
  min-width: 48px;
  height: 46px;
  padding: 0 10px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff, #d9dde5);
  border: 1px solid #aeb7c4;
  box-shadow: 0 6px 0 #9da6b4, 0 10px 18px rgba(35, 93, 143, 0.16);
  font-weight: 900;
  color: #1f2d3d;
}

.key.wide { min-width: 78px; }
.key.extra-wide { min-width: 116px; }
.key.space { min-width: 330px; }
.key.home-key::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 3px;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.45);
  bottom: 6px;
}
.key { position: relative; }
.key.next, .key.target { color: white; background: linear-gradient(180deg, #5ed2ff, #168ce5); border-color: #0a76c4; transform: translateY(-2px); box-shadow: 0 5px 0 #0a6fb2, 0 0 22px rgba(34,169,255,.65); }
.key.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #7ba4c2, 0 5px 12px rgba(35, 93, 143, 0.14); }
.key.ok, .key.correct { background: var(--green); color: white; box-shadow: 0 4px 0 #2fae62, 0 0 18px rgba(85, 217, 135, 0.65); }
.key.bad, .key.wrong { background: var(--red); color: white; animation: keyShake 0.22s ease; box-shadow: 0 4px 0 #d94d4d, 0 0 18px rgba(255, 111, 111, 0.65); }
.key.wrong::before {
  content: "×";
  position: absolute;
  inset: auto 4px 2px auto;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  border: 1px solid #cfefff;
}

.status-bar div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: #f2f9ff;
}

.status-bar span {
  grid-row: 1 / 3;
}

.status-bar strong {
  font-size: 18px;
  line-height: 1.1;
}

.status-bar small {
  color: var(--muted);
  font-weight: 800;
}

.form-card {
  max-width: 760px;
  padding: 24px;
}

label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 900;
}

input, textarea, select {
  width: 100%;
  border: 2px solid #b7e3ff;
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
  outline: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input {
  width: 22px;
  height: 22px;
}

.hint {
  color: var(--muted);
  line-height: 1.7;
}

.summary-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

.record-tools {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto auto;
  gap: 10px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid #e5f3ff;
  text-align: left;
}

th {
  color: var(--blue-dark);
  background: #eef8ff;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 55, 83, 0.35);
  z-index: 5;
}

.modal.hidden { display: none; }

.modal-card {
  width: min(480px, 100%);
  padding: 24px;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.result-stars {
  margin: 10px 0;
  color: #ffc400;
  font-size: 42px;
  letter-spacing: 0;
  animation: pop 0.45s ease;
}

#resultText {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  text-align: left;
}

#resultText strong {
  grid-column: 1 / -1;
  padding: 14px;
  border-radius: 16px;
  background: #fff6cc;
  color: #6b5000;
  text-align: center;
  font-size: 20px;
}

#resultText span {
  padding: 12px;
  border-radius: 14px;
  background: #eef8ff;
  font-weight: 800;
}

.sky-decor span {
  position: fixed;
  z-index: 0;
  user-select: none;
}

.cloud {
  width: 130px;
  height: 48px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
}

.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { width: 60px; height: 60px; left: 18px; top: -28px; }
.cloud::after { width: 76px; height: 76px; right: 12px; top: -38px; }
.cloud-a { left: 5%; top: 12%; }
.cloud-b { right: 8%; top: 20%; transform: scale(0.8); }
.star-a { left: 12%; bottom: 16%; color: #ffd84d; font-size: 34px; }
.star-b { right: 12%; top: 10%; color: #ffd84d; font-size: 28px; }
.ship { right: 8%; bottom: 12%; font-size: 46px; animation: float 2.8s ease-in-out infinite; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 980px) {
  .home-page.active, .training-console, .filter-panel {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    position: static;
  }

  .record-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .stats, .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chapter-head {
    display: block;
  }

  .hand-guide {
    grid-template-columns: 1fr;
  }
}

@keyframes keyShake {
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
