@font-face {
  font-family: 'Noto Sans Buginese';
  src: url('assets/NotoSansBuginese.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #23404d;
  --card: #ffffff;
  --accent: #ff7b54;
  --accent2: #ffb703;
  --good: #39b54a;
  --bad: #ef476f;
  --radius: 22px;
  --shadow: 0 8px 24px rgba(35, 64, 77, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.lontara { font-family: 'Noto Sans Buginese', sans-serif; }

.bg-scene { position: fixed; inset: 0; z-index: -1; }
.bg-scene svg { width: 100%; height: 100%; display: block; }

#app { max-width: 1080px; margin: 0 auto; padding: 14px 16px 42px; }

.screen { display: none; animation: fadeIn .35s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- tombol umum ---------- */
button { font-family: inherit; cursor: pointer; border: none; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 24px; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.9); }

.btn-big {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: clamp(26px, 5vw, 36px); font-weight: 700; letter-spacing: 1px;
  color: #fff; background: linear-gradient(180deg, #ff9a3d, #ff7b54);
  padding: 16px 62px; border-radius: 999px;
  box-shadow: 0 10px 0 #d95f38, var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-big:active { transform: translateY(6px); box-shadow: 0 4px 0 #d95f38, var(--shadow); }

.btn-main {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 20px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, #38b6cf, #219ebc);
  padding: 12px 30px; border-radius: 999px;
  box-shadow: 0 6px 0 #187893, var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-main:active { transform: translateY(4px); box-shadow: 0 2px 0 #187893, var(--shadow); }
.btn-main:disabled { filter: grayscale(.6); opacity: .55; cursor: not-allowed; }

.btn-check {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #4cc950, #2f9e44);
  padding: 13px 40px; border-radius: 999px;
  box-shadow: 0 6px 0 #20702f, var(--shadow);
}
.btn-check:active { transform: translateY(4px); box-shadow: 0 2px 0 #20702f, var(--shadow); }

.btn-ghost {
  font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 19px; font-weight: 600;
  background: #fff; color: var(--ink); border: 3px solid #bfe3ee;
  padding: 10px 24px; border-radius: 999px; box-shadow: var(--shadow);
}
.btn-ghost:active { transform: scale(.95); }

/* ---------- layar pembuka ---------- */
.topbar { display: flex; justify-content: flex-end; gap: 10px; }

.home-card {
  background: rgba(255, 255, 255, .88);
  border-radius: 30px; box-shadow: var(--shadow);
  padding: 26px 22px 30px; margin-top: 10px;
  text-align: center; backdrop-filter: blur(3px);
}
.mascots { display: flex; justify-content: center; gap: 8px; }
.mascot-img { height: clamp(150px, 32vw, 250px); width: auto; filter: drop-shadow(0 8px 10px rgba(0,0,0,.15)); animation: bob 3s ease-in-out infinite; }
.mascot-img:last-child { animation-delay: 1.2s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.game-title {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: clamp(44px, 9vw, 78px); font-weight: 700; line-height: 1.05;
  margin: 10px 0 4px; color: #ef6351;
  text-shadow: 0 3px 0 #ffd9a0;
}
.game-title span { color: #219ebc; }
.tagline { font-size: clamp(16px, 3.4vw, 21px); font-weight: 700; margin: 6px 0 22px; }
.total-stars { margin-top: 20px; font-size: 18px; font-weight: 800; }

/* ---------- kepala layar ---------- */
.screen-head { display: flex; align-items: center; gap: 14px; }
.screen-head h2 {
  font-family: 'Fredoka', 'Nunito', sans-serif; font-size: clamp(24px, 5vw, 34px);
  margin: 0; flex: 1; text-align: center; color: #fff;
  text-shadow: 0 2px 6px rgba(23, 74, 96, .45);
}
.head-stars {
  background: var(--card); border-radius: 999px; padding: 10px 18px;
  font-size: 19px; font-weight: 800; box-shadow: var(--shadow); min-width: 52px; text-align: center;
}
.menu-sub {
  text-align: center; font-weight: 800; font-size: clamp(15px, 3vw, 19px);
  color: #fff; text-shadow: 0 2px 5px rgba(23, 74, 96, .5); margin: 14px 6px 20px;
}

/* ---------- kartu level ---------- */
.level-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.level-card {
  border-radius: var(--radius); padding: 20px 16px 16px; text-align: left;
  color: #fff; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .15s ease;
}
.level-card:hover { transform: translateY(-4px); }
.level-card:active { transform: scale(.97); }
.level-card .lv-emoji { font-size: 44px; display: block; margin-bottom: 6px; }
.level-card h3 { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 22px; margin: 0 0 4px; }
.level-card p { margin: 0; font-size: 14.5px; font-weight: 700; opacity: .95; line-height: 1.35; }
.level-card .lv-stars { position: absolute; top: 12px; right: 14px; font-size: 17px; letter-spacing: 2px; }
.lv-0 { background: linear-gradient(150deg, #ff9a3d, #ef6351); }
.lv-1 { background: linear-gradient(150deg, #4cc9f0, #4361ee); }
.lv-2 { background: linear-gradient(150deg, #f72585, #b5179e); }
.lv-3 { background: linear-gradient(150deg, #ffd60a, #fb8500); }
.lv-4 { background: linear-gradient(150deg, #80ed99, #2f9e44); }
.lv-5 { background: linear-gradient(150deg, #c77dff, #7b2cbf); }
.lv-6 { background: linear-gradient(150deg, #ff70a6, #e5383b); }
.lv-7 { background: linear-gradient(150deg, #ffd93d, #f77f00); }

/* ---------- area permainan ---------- */
.game-info {
  text-align: center; font-weight: 800; color: #fff; font-size: clamp(15px, 3vw, 18px);
  text-shadow: 0 2px 5px rgba(23, 74, 96, .5); margin: 12px 4px 6px; min-height: 24px;
}
.game-content {
  background: rgba(255, 255, 255, .93); border-radius: 28px; box-shadow: var(--shadow);
  padding: 20px 18px 24px; margin-top: 8px; min-height: 340px;
}
.instruction { text-align: center; font-size: clamp(17px, 3.6vw, 21px); font-weight: 800; margin: 2px 0 16px; }
.round-dots { text-align: center; font-size: 15px; letter-spacing: 5px; margin-bottom: 12px; }
.controls-row { display: flex; justify-content: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }

/* aksara */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 11px; }
.letter-tile {
  background: #eaf7fd; border: 3px solid #bfe3ee; border-radius: 16px;
  padding: 10px 2px 7px; text-align: center; transition: transform .1s ease, background .1s ease;
}
.letter-tile:active { transform: scale(.93); background: #d3eefb; }
.letter-tile .glyph { font-size: 34px; line-height: 1.15; display: block; }
.letter-tile .latin { font-size: 14px; font-weight: 800; color: #219ebc; }
.letter-tile.seen { background: #e2f7e4; border-color: #9be29d; }

.big-display {
  text-align: center; background: #fff7e0; border: 3px dashed #ffb703; border-radius: 20px;
  padding: 14px; margin-bottom: 18px; min-height: 148px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.big-display .glyph { font-size: 78px; line-height: 1.1; }
.big-display .latin-big { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 34px; font-weight: 700; color: #ef6351; }
.big-display .hint { font-weight: 700; color: #8aa3ad; }

.vowel-row { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; margin: 6px 0 18px; }
.vowel-chip {
  background: #fdf0f5; border: 3px solid #f5b8d0; border-radius: 14px; padding: 6px 13px; text-align: center;
}
.vowel-chip .glyph { font-size: 30px; display: block; line-height: 1.15; }
.vowel-chip .latin { font-size: 13px; font-weight: 800; color: #d6336c; }
.section-label { text-align: center; font-family: 'Fredoka', 'Nunito', sans-serif; font-weight: 600; font-size: 19px; margin: 10px 0 8px; }

/* pilihan (tebak bunyi & kuis) */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-width: 560px; margin: 0 auto; }
.option-btn {
  background: #eaf7fd; border: 3px solid #bfe3ee; border-radius: 18px;
  padding: 16px 10px; font-size: 24px; font-weight: 800; color: var(--ink);
  transition: transform .1s ease;
}
.option-btn .glyph { font-size: 44px; }
.option-btn:active { transform: scale(.95); }
.option-btn.correct { background: #d9f7dc; border-color: var(--good); }
.option-btn.wrong { background: #ffe0e8; border-color: var(--bad); animation: shake .4s ease; }
button.speaker-btn {
  display: block; margin: 0 auto 16px; background: linear-gradient(180deg, #ffd93d, #ffb703);
  border-radius: 999px; padding: 13px 34px; font-size: 21px; font-weight: 800; color: #6b4e00;
  box-shadow: 0 5px 0 #cc8f00, var(--shadow); font-family: 'Fredoka', 'Nunito', sans-serif;
}
button.speaker-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #cc8f00, var(--shadow); }
.prompt-word { text-align: center; font-family: 'Fredoka', 'Nunito', sans-serif; font-size: clamp(28px, 6vw, 40px); font-weight: 700; margin-bottom: 14px; }
.timer-bar { height: 14px; background: #e5eef2; border-radius: 99px; overflow: hidden; max-width: 560px; margin: 0 auto 16px; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #4cc950, #ffb703, #ef476f); border-radius: 99px; transition: width .2s linear; }

/* ---------- drag & drop ---------- */
.match-board { display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }
.match-row { display: flex; align-items: stretch; gap: 10px; }
.anchor-card {
  flex: 1; background: #eaf7fd; border: 3px solid #bfe3ee; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: clamp(19px, 4.4vw, 25px); padding: 10px 8px; text-align: center; min-height: 62px;
}
.anchor-card .emoji-big { font-size: 40px; }
.slot {
  flex: 1; border: 3px dashed #9fc9d9; border-radius: 16px; min-height: 62px;
  display: flex; align-items: center; justify-content: center; background: #fbfdff;
  transition: background .12s ease, border-color .12s ease; padding: 4px;
}
.slot.drop-hover { background: #fff3bf; border-color: var(--accent2); }
.slot.filled { border-style: solid; border-color: #7fc8bc; background: #eefbf7; }
.slot.locked-ok { border: 3px solid var(--good) !important; background: #d9f7dc !important; }

.tray {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  background: #fdf6e3; border: 3px dashed #ecd9a0; border-radius: 18px;
  padding: 14px 10px; margin-top: 20px; min-height: 74px;
}
.tray:empty::after { content: '🎉 Semua kartu sudah terpasang!'; font-weight: 800; color: #b08900; }

.tile {
  background: #fff; border: 3px solid #ffb703; border-radius: 15px;
  padding: 9px 16px; font-size: clamp(18px, 4.2vw, 23px); font-weight: 800; color: var(--ink);
  box-shadow: 0 4px 10px rgba(35, 64, 77, .15); cursor: grab; touch-action: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.tile .glyph { font-size: clamp(24px, 5.4vw, 32px); }
.tile.in-slot { width: 100%; border-color: #7fc8bc; box-shadow: none; }
.tile.selected { outline: 4px solid #4cc9f0; outline-offset: 2px; }
.tile.locked { border-color: var(--good); background: #d9f7dc; cursor: default; }
.tile.dragging {
  position: fixed; z-index: 999; pointer-events: none; opacity: .95;
  box-shadow: 0 14px 28px rgba(35, 64, 77, .35); transform: translate(-50%, -50%) scale(1.06) rotate(-2deg);
}
.tile.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}

/* susun: deretan slot horizontal */
.seq-slots { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 8px 0 4px; }
.seq-slots .slot { flex: 0 1 130px; min-height: 76px; }
.word-hint { text-align: center; margin-bottom: 6px; }
.word-hint .emoji-big { font-size: 64px; display: block; }
.word-hint .arti { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 24px; font-weight: 600; }

/* tema */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
.theme-card {
  border-radius: 18px; padding: 18px 10px; color: #fff; text-align: center; box-shadow: var(--shadow);
  font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 19px; font-weight: 600;
}
.theme-card .t-emoji { font-size: 40px; display: block; margin-bottom: 4px; }
.theme-card .t-done { font-size: 13px; font-family: 'Nunito', sans-serif; font-weight: 800; }
.study-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.study-card {
  background: #eaf7fd; border: 3px solid #bfe3ee; border-radius: 16px; padding: 13px 6px 10px; text-align: center;
}
.study-card:active { transform: scale(.94); }
.study-card .emoji-big { font-size: 38px; display: block; }
.study-card .bugis { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 21px; font-weight: 600; display: block; }
.study-card .arti { font-size: 14.5px; font-weight: 700; color: #5b7c8a; }
.study-card .num { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 30px; font-weight: 700; color: #ef6351; display: block; }

/* ---------- popup ---------- */
.popup-overlay {
  position: fixed; inset: 0; background: rgba(20, 45, 58, .55);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.popup-overlay.hidden { display: none; }
.popup-card {
  background: #fff; border-radius: 28px; box-shadow: var(--shadow); max-width: 430px; width: 100%;
  padding: 22px; text-align: center; animation: pop .3s ease;
  max-height: 92vh; overflow-y: auto;
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.popup-mascot { height: 150px; width: auto; }
.popup-bubble h3 { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 30px; margin: 8px 0 4px; color: #ef6351; }
.popup-bubble p { font-size: 17.5px; font-weight: 700; margin: 0 0 8px; }
.popup-stars { font-size: 38px; letter-spacing: 6px; min-height: 46px; }
.popup-stars .off { filter: grayscale(1); opacity: .3; }
.popup-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.help-card { text-align: left; }
.help-card h3 { font-family: 'Fredoka', 'Nunito', sans-serif; text-align: center; font-size: 26px; margin-top: 0; }
.help-list { font-size: 16.5px; font-weight: 600; line-height: 1.55; padding-left: 20px; }
.help-note { font-weight: 700; background: #fff7e0; border-radius: 14px; padding: 10px 13px; }
.help-card .btn-main { display: block; margin: 14px auto 0; }

.score-big { font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 46px; font-weight: 700; text-align: center; color: #219ebc; }

@media (max-width: 520px) {
  .anchor-card, .slot { min-height: 56px; }
  .level-grid { grid-template-columns: 1fr 1fr; }
  .level-card h3 { font-size: 18px; }
  .level-card p { font-size: 12.5px; }
  .level-card .lv-emoji { font-size: 34px; }
}

/* ---------- utamakan landscape ---------- */
@media (orientation: landscape) and (min-width: 700px) {
  #app { max-width: 1240px; }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
  .match-board { max-width: 860px; }
  .options-grid, .timer-bar { max-width: 720px; }
  .letter-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .home-card { padding: 20px 30px 24px; }
  .mascot-img { height: clamp(130px, 26vh, 210px); }
  .game-content { min-height: 300px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #app { padding-top: 8px; padding-bottom: 24px; }
  .mascot-img { height: 110px; }
  .game-title { font-size: 44px; }
  .game-content { min-height: 260px; padding: 14px 16px 18px; }
  .big-display { min-height: 110px; padding: 8px; }
  .big-display .glyph { font-size: 56px; }
}

/* ---------- petunjuk putar HP (hanya portrait, layar kecil) ---------- */
.rotate-hint { display: none; }
.rotate-hint.hidden { display: none !important; }
@media (orientation: portrait) and (max-width: 899px) {
  .rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 1200;
    background: rgba(20, 45, 58, .6);
    align-items: center; justify-content: center; padding: 22px;
  }
  .rotate-card {
    background: #fff; border-radius: 26px; box-shadow: var(--shadow);
    padding: 26px 24px; text-align: center; max-width: 340px; width: 100%;
    animation: pop .3s ease;
  }
  .rotate-emoji { font-size: 58px; animation: bob 2.4s ease-in-out infinite; }
  .rotate-card p { font-size: 19px; font-weight: 800; margin: 10px 0 18px; line-height: 1.4; }
}
