:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --panel: #fffdf8;
  --accent: #ff8a5b;
  --accent-2: #4fb3d8;
  --accent-3: #ffd166;
  --accent-4: #a56b3f;
  --text: #4f3b2d;
  --muted: #7a5f4a;
  --success: #2f8f5b;
  --soft: #fff3e8;
  --border: #f2d0a4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #fff8ef 0%, #ffe7c2 45%, #dff4ff 100%);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #ffbf73 100%);
  color: #fff;
  border-radius: 24px;
  padding: 24px 28px;
  box-shadow: 0 16px 30px rgba(79, 179, 216, 0.2);
  position: relative;
  overflow: hidden;
}

.hero-illustration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0.18;
  pointer-events: none;
}

.hero > div {
  position: relative;
  z-index: 1;
}

.eyebrow {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.8rem;
  opacity: 0.95;
  margin: 0 0 8px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.subtitle {
  margin: 0;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.95);
}

.top-panel,
.bottom-panel {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.top-panel {
  grid-template-columns: 1fr;
}

.bottom-panel {
  grid-template-columns: 1fr 1fr;
}

.piece-card,
.drop-zone-card,
.right-panel,
.left-panel {
  background: var(--panel);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 22px rgba(79, 179, 216, 0.12);
  border: 2px solid var(--border);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.palette-group {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.palette-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.piece-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.symbol-rows .piece {
  width: 100%;
}

.piece-row {
  display: contents;
}

.piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff0f4;
  color: #c04b69;
  font-size: 1.15rem;
  font-weight: 700;
  border: 2px dashed #ffb1c2;
  cursor: grab;
  user-select: none;
}

/* Card-style pieces for child-friendly interaction */
.piece {
  min-width: 60px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf8, #ffe6c4);
  color: var(--accent-4);
  font-size: 1.25rem;
  box-shadow: 0 6px 14px rgba(79, 179, 216, 0.12);
  border: 1px solid rgba(79, 179, 216, 0.16);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.piece:focus {
  outline: 3px solid rgba(110,197,184,0.18);
  transform: translateY(-4px);
}

.piece:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px rgba(156,45,68,0.14);
}

.piece:active {
  transform: translateY(0);
  cursor: grabbing;
}

.piece[draggable="true"] {
  cursor: grab;
}

.drop-zone {
  min-height: 90px;
  border: 2px dashed var(--accent-2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #f3fbff;
  margin-top: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}


.drop-zone-card + .drop-zone-card {
  margin-top: 12px;
}

/* Zhuyin-style drop-grid layout */
.zhuyin-layout .drop-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.zhuyin-layout .drop-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zhuyin-layout .drop-row {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 10px;
  align-items: start;
}

.zhuyin-layout .drop-box label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.drop-box .drop-zone.small {
  min-height: 54px;
  width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.drop-box {
  background: #fff;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed #f2e6ea;
}

.drop-zone.drag-over {
  border-color: var(--accent-2);
  transform: scale(1.01);
}

.drop-zone .placed-piece {
  color: #226d89;
  background: #dff5ff;
  border-color: var(--accent-2);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

#confirmBtn {
  background: linear-gradient(90deg, var(--accent), #ffb76d);
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 179, 216, 0.18);
}

.secondary {
  background: #ffe8cc;
  color: var(--accent-4);
}

.message {
  margin-top: 12px;
  min-height: 20px;
  color: var(--success);
  font-weight: 700;
}

.assembled-syllable {
  min-height: 2.2rem;
  margin-bottom: 8px;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

.word-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.word-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff9f1;
  border: 1px solid #f3d7b1;
}

.word-title {
  font-weight: 700;
}

.word-zhuyin {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.play-btn {
  background: #e8f7ff;
  color: #2b7fa5;
  padding: 8px 12px;
  font-size: 0.95rem;
}

@media (max-width: 860px) {
  .top-panel,
  .bottom-panel {
    grid-template-columns: 1fr;
  }
}

/* Tabs for palette */
.tabs {
  margin-top: 8px;
}

.tab-buttons {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-button {
  background: transparent;
  border: 1px solid rgba(139,111,111,0.18);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tab-button.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 179, 216, 0.16);
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-panel {
  display: block;
}

.tab-panel[hidden] {
  display: none;
}
