@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

@font-face {
  font-family: 'FZKaiZ03';
  src: url('/assets/fonts/FZKai-Z03-Regular.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PK Maehongson';
  src: url('/assets/fonts/PK-Maehongson-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root{
  --font-thai:'TH Sarabun New','Sarabun','Noto Sans Thai',sans-serif;
  --font-chinese:'FZKaiZ03','STKaiti','KaiTi','Noto Serif SC',serif;
  --font-cute:'PK Maehongson','TH Sarabun New','Sarabun',sans-serif;
  --bg:#fff7ef;
  --text:#261f3d;
  --muted:#73688e;
  --surface:#fff;
  --line:rgba(40,24,64,.1);
  --green:#24c7a5;
  --pink:#ff7aa7;
  --yellow:#ffd34d;
  --blue:#41b8f4;
  --shadow:0 16px 34px rgba(78,44,99,.12);
}
*{box-sizing:border-box}
.hidden{display:none!important}
body{
  margin:0;
  min-height:100vh;
  font-family:var(--font-thai);
  color:var(--text);
  background:var(--bg);
}
body::before{
  content:'';
  position:fixed;
  inset:0;
  z-index:-2;
  background-image:
    radial-gradient(circle, rgba(255,122,167,.18) 2px, transparent 2.5px),
    radial-gradient(circle, rgba(36,199,165,.18) 2px, transparent 2.5px),
    radial-gradient(circle, rgba(255,211,77,.2) 2px, transparent 2.5px);
  background-size:68px 68px,84px 84px,100px 100px;
  background-position:0 0,28px 36px,62px 12px;
}
a{color:inherit}
.shell{width:min(980px,100%);margin:0 auto;padding:16px 18px 34px}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none}
.brand img{width:132px;height:auto;filter:drop-shadow(0 8px 16px rgba(5,80,58,.18))}
.back-link{
  text-decoration:none;
  padding:9px 14px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--line);
  color:#5f5577;
  font-weight:700;
}
.hero{
  display:grid;
  grid-template-columns:minmax(0,1fr) 220px;
  gap:20px;
  align-items:center;
  margin:6px 0 18px;
}
.title-block h1{margin:0 0 6px;font-family:var(--font-cute);font-size:44px;font-weight:500;letter-spacing:0}
.title-block p{margin:0;color:var(--muted);font-size:22px;line-height:1.25}
.hero-mark{
  min-height:160px;
  border-radius:18px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#facc15,#2dd4bf 58%,#ff8fb3);
  box-shadow:var(--shadow);
}
.hero-mark span{font-family:var(--font-chinese);font-size:94px;color:#101827;text-shadow:0 3px 0 rgba(255,255,255,.35)}
.game-hero-banner{
  display:block;
  width:min(100%,960px);
  margin:0 auto 14px;
}
.game-hero-banner img{
  display:block;
  width:100%;
  height:clamp(170px,26vw,280px);
  object-fit:cover;
  object-position:center;
  border-radius:18px;
  filter:drop-shadow(0 16px 28px rgba(78,44,99,.12));
}
.mode-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.mode-card,.panel{
  background:rgba(255,255,255,.88);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}
.mode-card{
  display:grid;
  grid-template-columns:56px minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  padding:14px;
  text-decoration:none;
}
.mode-icon{
  width:56px;height:56px;border-radius:15px;
  display:grid;place-items:center;
  background:#111827;color:#facc15;
  font-family:var(--font-chinese);font-size:34px;
}
.mode-card h2{margin:0;font-size:25px;line-height:1.05}
.mode-card p{margin:4px 0 0;color:var(--muted);font-size:18px;line-height:1.15}
.go{font-weight:800;color:#0f766e}
.chooser{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px}
.panel{padding:16px}
.panel h2,.panel h3{margin:0 0 10px;font-size:26px}
.button-row{display:flex;flex-wrap:wrap;gap:10px}
.pill,.primary,.option-btn{
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:var(--text);
  font-family:var(--font-thai);
  font-weight:800;
  font-size:18px;
  padding:8px 14px;
  cursor:pointer;
  text-decoration:none;
}
.pill{
  min-width:104px;
  justify-content:center;
  display:inline-flex;
  align-items:center;
  border:2px solid rgba(255,255,255,.88);
  color:#2a2140;
  box-shadow:0 8px 18px rgba(78,44,99,.1);
  transition:transform .16s,box-shadow .16s,filter .16s;
}
.pill:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 24px rgba(78,44,99,.15);
  filter:saturate(1.05);
}
.pill:disabled{
  opacity:.45;
  cursor:not-allowed;
  transform:none;
  filter:grayscale(.25);
}
.pill.color-0{background:linear-gradient(135deg,#ff7aa7,#ffd166);}
.pill.color-1{background:linear-gradient(135deg,#6ee7b7,#67e8f9);}
.pill.color-2{background:linear-gradient(135deg,#fde68a,#fca5a5);}
.pill.color-3{background:linear-gradient(135deg,#c4b5fd,#fbcfe8);}
.pill.color-4{background:linear-gradient(135deg,#93c5fd,#a7f3d0);}
.pill.color-5{background:linear-gradient(135deg,#f9a8d4,#fef3c7);}
.primary{
  border:0;
  background:linear-gradient(135deg,#ff7aa7,#ffd34d);
  box-shadow:0 8px 18px rgba(255,122,167,.22);
}
.game-layout{display:grid;grid-template-columns:minmax(0,1fr) 270px;gap:16px;align-items:start}
.play-card{
  position:relative;
  min-height:520px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
  text-align:center;
}
.chinese-big{
  font-family:var(--font-chinese);
  font-size:clamp(90px,18vw,178px);
  line-height:1;
  max-width:100%;
  white-space:nowrap;
  word-break:keep-all;
  overflow-wrap:normal;
}
.pinyin{font-size:25px;color:var(--muted);letter-spacing:1.5px;line-height:1.15;max-width:100%}
.thai{font-size:31px;font-weight:800;line-height:1.15}
.writer-chinese{
  font-family:var(--font-chinese);
  font-size:clamp(30px,7vw,48px);
  line-height:1;
  color:#6d28d9;
  background:rgba(196,181,253,.2);
  border:1px solid rgba(124,58,237,.18);
  border-radius:999px;
  padding:5px 16px 8px;
  white-space:nowrap;
  max-width:100%;
}
.writer-box{
  width:min(360px,82vw);
  height:min(360px,82vw);
  display:grid;
  place-items:center;
  border-radius:18px;
  background:linear-gradient(135deg,#fff,#fff8de);
  border:2px dashed rgba(38,31,61,.18);
}
#writer-target{width:100%;height:100%}
.writer-blank{width:100%;height:100%}
.setup-mark{
  font-family:var(--font-chinese);
  font-size:clamp(82px,18vw,150px);
  line-height:1;
  color:rgba(109,40,217,.22);
}
.status-line{
  min-height:30px;
  color:var(--muted);
  font-size:19px;
  font-weight:800;
  line-height:1.25;
  padding:2px 10px;
  border-radius:999px;
}
.status-line.info{color:#0f766e;background:rgba(45,212,191,.13)}
.status-line.success{color:#be5b00;background:linear-gradient(90deg,rgba(255,211,77,.28),rgba(255,122,167,.18))}
.status-line.warn{color:#b42318;background:rgba(254,202,202,.42)}
.status-line.hint{color:#5b21b6;background:rgba(196,181,253,.24)}
.hud{display:grid;gap:10px}
.hud-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-size:20px;
  padding:8px 10px;
  border-radius:14px;
  background:linear-gradient(135deg,rgba(255,255,255,.92),rgba(224,247,250,.66));
  border:1px solid rgba(59,130,246,.12);
}
.hud-row b{
  color:#0b3b78;
  font-weight:900;
  text-shadow:0 1px 0 rgba(255,255,255,.8);
}
.meter{height:14px;border-radius:999px;background:rgba(38,31,61,.09);overflow:hidden}
.meter span{display:block;height:100%;width:100%;background:linear-gradient(90deg,#24c7a5,#ffd34d,#ff7aa7);transition:width .2s linear}
.options{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(520px,100%)}
.setup-options{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:8px;
  width:min(560px,100%);
}
.option-btn{
  border-radius:16px;
  min-height:64px;
  font-size:22px;
  line-height:1.1;
  overflow-wrap:anywhere;
}
.option-btn.good{background:#dcfce7;border-color:#86efac}
.option-btn.bad{background:#fee2e2;border-color:#fca5a5}
.sparkle-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:grid;
  place-items:center;
  overflow:hidden;
  border-radius:18px;
}
.sparkle-layer i{
  position:absolute;
  width:10px;
  height:10px;
  border-radius:999px;
  background:linear-gradient(135deg,#ffd34d,#ff7aa7);
  box-shadow:0 0 12px rgba(255,211,77,.65);
  transform:translate(0,0) scale(.2);
  opacity:0;
  animation:sparkleOut .72s var(--delay,0ms) ease-out both;
}
.sparkle-layer i:nth-child(3n){background:linear-gradient(135deg,#67e8f9,#6ee7b7)}
.sparkle-layer i:nth-child(3n+1){background:linear-gradient(135deg,#c4b5fd,#f9a8d4)}
@keyframes sparkleOut{
  0%{opacity:0;transform:translate(0,0) scale(.2) rotate(0)}
  18%{opacity:1}
  100%{opacity:0;transform:translate(var(--x),var(--y)) scale(1) rotate(180deg)}
}
.bomb-layout .play-card{overflow:hidden}
.bomb-card::before{
  content:'';
  position:absolute;
  inset:0 0 auto;
  height:5px;
  background:linear-gradient(90deg,#38bdf8,#67e8f9,#a78bfa);
}
.bomb-card.exploding::after{
  content:'';
  position:absolute;
  inset:50%;
  width:26px;
  height:26px;
  border-radius:999px;
  background:
    radial-gradient(circle,#fff7ed 0 14%,#facc15 15% 30%,#fb923c 31% 48%,#dc2626 49% 62%,transparent 63%);
  transform:translate(-50%,-50%) scale(.2);
  animation:bombBoom .64s ease-out both;
  pointer-events:none;
}
@keyframes bombBoom{
  0%{opacity:.96;transform:translate(-50%,-50%) scale(.2) rotate(0)}
  64%{opacity:.94;transform:translate(-50%,-50%) scale(18) rotate(16deg)}
  100%{opacity:0;transform:translate(-50%,-50%) scale(24) rotate(22deg)}
}
.bomb-option{
  border:2px dashed rgba(56,189,248,.72);
  background:linear-gradient(135deg,#effcff,#dff7ff);
  color:#123a73;
  box-shadow:0 8px 18px rgba(14,116,144,.1);
}
.bomb-option:hover{
  border-style:solid;
  background:linear-gradient(135deg,#dff7ff,#c7eeff);
  transform:translateY(-2px);
}
.bomb-option.good{
  border-style:solid;
  background:linear-gradient(135deg,#34d399,#a7f3d0);
  color:#053b2c;
}
.bomb-option.bad{
  border-style:solid;
  background:linear-gradient(135deg,#fb7185,#fecdd3);
  color:#5f0f1f;
}
.time-choice{
  display:grid;
  gap:2px;
  min-height:76px;
  border:2px solid rgba(56,189,248,.32);
  background:linear-gradient(135deg,#e0f7ff,#fff);
  color:#123a73;
}
.time-choice strong{font-size:34px;line-height:1}
.time-choice span{font-size:14px;color:#0f6b9d}
.time-choice.active,
.time-choice:hover{
  background:linear-gradient(135deg,#67e8f9,#c4b5fd);
  border-color:#38bdf8;
  color:#0b2f66;
}
.setup-choice-group{
  grid-column:1/-1;
  display:grid;
  gap:8px;
}
.setup-choice-title{
  font-size:18px;
  font-weight:900;
  color:#0b3b78;
  text-align:center;
}
.setup-choice-grid{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:8px;
}
.start-round-btn{
  grid-column:1/-1;
  min-height:54px;
  border-radius:18px;
  font-size:22px;
  font-family:var(--font-thai);
  font-weight:900;
}
.toggle-wide{width:100%;min-width:0}
.level-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.note{color:var(--muted);font-size:18px;line-height:1.25}
@media(max-width:760px){
  .shell{padding:10px 12px 24px}
  .topbar{align-items:center}
  .brand img{width:108px}
  .hero,.game-layout,.chooser,.mode-grid{grid-template-columns:1fr}
  .hero-mark{min-height:116px}
  .hero-mark span{font-size:72px}
  .game-hero-banner{margin:0 0 12px}
  .game-hero-banner img{
    height:auto;
    max-height:132px;
    object-fit:contain;
    border-radius:14px;
  }
  .title-block h1{font-size:34px}
  .title-block p{font-size:18px}
  .mode-card{grid-template-columns:46px minmax(0,1fr) auto;padding:11px}
  .mode-icon{width:46px;height:46px;font-size:28px}
  .mode-card h2{font-size:21px}
  .mode-card p{font-size:15px}
  .play-card{
    min-height:0;
    padding:12px;
    gap:7px;
  }
  .thai{font-size:27px}
  .pinyin{font-size:19px;letter-spacing:.5px;overflow-wrap:anywhere}
  .writer-chinese{font-size:30px;padding:4px 12px 7px}
  .writer-box{
    width:min(260px,72vw);
    height:min(260px,72vw);
    border-radius:16px;
  }
  .status-line{min-height:22px;font-size:16px}
  .button-row{gap:7px;justify-content:center}
  .pill,.primary,.option-btn{
    min-width:88px;
    padding:7px 10px;
    font-size:16px;
  }
  .hud{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px;
    padding:10px;
  }
  .hud h2,.hud .note{display:none}
  .hud-row{
    display:grid;
    gap:2px;
    align-content:center;
    justify-items:center;
    min-height:44px;
    padding:5px 7px;
    border-radius:12px;
    background:rgba(255,255,255,.66);
    font-size:16px;
    text-align:center;
  }
  .hud-row b{font-size:18px}
  .options{grid-template-columns:1fr}
  .setup-options{grid-template-columns:repeat(3,minmax(0,1fr))}
  .setup-choice-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .chinese-big{font-size:clamp(58px,16vw,96px)}
  .time-choice strong{font-size:28px}
  .time-choice span{font-size:12px}
}
