:root {
  --tido: #3fb6cf;
  --sola: #ff7aa2;
  --gold: #ffd166;
  --ink: #1b1446;
  --font: "Baloo 2", "Arial Rounded MT Bold", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  font-family: var(--font);
  color: #fff;
  background: radial-gradient(circle at 20% 10%, #5b3ea8 0, transparent 45%),
              radial-gradient(circle at 85% 90%, #c2477a 0, transparent 45%),
              linear-gradient(160deg, #2b1d5c, #1d3b78);
  background-attachment: fixed;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
img { -webkit-user-drag: none; pointer-events: none; }

#safe {
  position: fixed; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game {
  position: fixed; inset: 0; display: none;
  touch-action: none; background: #2f7d32;
}
body.playing { overflow: hidden; position: fixed; inset: 0; }
body.playing #game { display: block; }

/* ---------- màn hình ---------- */
.screen {
  display: none;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.active { display: flex; align-items: center; justify-content: center; }
body.playing .screen { display: none; }

.icon-btn {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  font-size: 26px; width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.15); z-index: 5;
}

.hub-wrap { width: 100%; max-width: 980px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.hero { text-align: center; }
.logo {
  margin: 0; line-height: .95; font-weight: 800;
  font-size: clamp(44px, 9vw, 84px);
  color: var(--gold);
  text-shadow: 0 5px 0 #b5651d, 0 10px 18px rgba(0,0,0,.4);
  letter-spacing: 1px;
}
.logo span { color: #fff; }
.logo small {
  display: block; font-size: .42em; letter-spacing: 8px; color: #fff;
  text-shadow: 0 3px 0 #c2477a;
}
.kids { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin-top: 6px; }
.kids img { height: clamp(120px, 24vh, 220px); animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(0,0,0,.35)); }
.kids img:last-child { animation-delay: -1.2s; }
#today:empty { display: none; }
#today { font-size: 22px; margin: 6px 0 0; background: rgba(255,209,102,.2); padding: 4px 16px; border-radius: 99px; animation: pulse 1s infinite; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: 100%; }
.card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 132px; padding: 14px 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, #3fb6cf, #23849c);
  box-shadow: 0 7px 0 #17657a, 0 12px 20px rgba(0,0,0,.3);
  transition: transform .1s;
}
.card:active { transform: translateY(4px); box-shadow: 0 3px 0 #17657a; }
.card.main { grid-column: 1 / -1; background: linear-gradient(180deg, #4caf50, #2e7d32); box-shadow: 0 7px 0 #1b5e20, 0 12px 20px rgba(0,0,0,.3); }
.card.pink { background: linear-gradient(180deg, #ff8fb1, #e0567f); box-shadow: 0 7px 0 #a8355a, 0 12px 20px rgba(0,0,0,.3); }
.card.soon { background: rgba(255,255,255,.1); box-shadow: none; opacity: .75; }
.card .emo { font-size: 44px; line-height: 1; }
.card img { height: 62px; }
.card b { font-size: 26px; line-height: 1.1; margin-top: 4px; }
.card i { font-style: normal; font-size: 16px; opacity: .92; }
.card.locked img { filter: grayscale(.6); }
.card.today { animation: glow 1s infinite alternate; }
.card.shake { animation: shake .4s; }

.panel {
  width: 100%; max-width: 640px;
  background: rgba(20, 14, 60, .72);
  border: 3px solid rgba(255,255,255,.18);
  border-radius: 28px; padding: 20px 22px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,.4);
}
.panel.narrow { max-width: 460px; }
.panel h2 { margin: 0 0 10px; font-size: 34px; color: var(--gold); text-shadow: 0 3px 0 #8a4b10; }
.label { margin: 12px 0 6px; font-size: 18px; opacity: .85; }
.hint { font-size: 17px; opacity: .85; margin: 10px 0; }
.hint.small { font-size: 15px; }

.seg { display: flex; gap: 8px; background: rgba(0,0,0,.25); padding: 6px; border-radius: 18px; }
.seg button { flex: 1; padding: 10px 6px; font-size: 22px; font-weight: 700; border-radius: 13px; }
.seg.small button { font-size: 18px; padding: 8px 4px; }
.seg button.sel { background: var(--gold); color: var(--ink); }

.pickers { display: flex; gap: 12px; justify-content: center; }
.pick {
  flex: 1; max-width: 170px; padding: 8px; border-radius: 20px;
  background: rgba(255,255,255,.08); border: 4px solid transparent;
  display: flex; flex-direction: column; align-items: center;
}
.pick img { height: 110px; }
.pick b { font-size: 22px; }
.pick.sel { border-color: var(--tido); background: rgba(63,182,207,.25); }
.pick.pink.sel { border-color: var(--sola); background: rgba(255,122,162,.25); }

.vs { display: flex; align-items: center; justify-content: center; gap: 14px; }
.vs div { display: flex; flex-direction: column; align-items: center; }
.vs img { height: 120px; }
.vs b { font-size: 26px; }
.vs i { font-style: normal; font-size: 15px; opacity: .85; }
.vs span { font-size: 44px; font-weight: 800; color: var(--gold); text-shadow: 0 3px 0 #8a4b10; }

.big-btn {
  display: block; width: 100%; margin-top: 12px; padding: 12px;
  font-size: 30px; font-weight: 800; color: var(--ink);
  background: linear-gradient(180deg, #ffe08a, #ffb627);
  border-radius: 20px; box-shadow: 0 6px 0 #b5651d;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b5651d; }
.back { margin-top: 12px; font-size: 19px; opacity: .8; padding: 6px 14px; }

.ref-line { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 0; font-size: 18px; }
.ref-line img { height: 46px; }
.ref-line em { font-style: normal; }
.ref-line span { background: #fff; color: var(--ink); font-weight: 700; padding: 4px 14px; border-radius: 16px; position: relative; }

.legend {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px;
  text-align: left; font-size: 15px; line-height: 1.25;
  background: rgba(0,0,0,.25); border-radius: 16px; padding: 10px 12px;
}
.legend div { display: flex; gap: 6px; align-items: baseline; }
.legend .ic { font-size: 20px; flex: 0 0 26px; }
.legend b { white-space: nowrap; }
.legend span { opacity: .8; }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  background: rgba(10, 6, 30, .6);
  padding: 16px;
  overflow-y: auto;
}
.overlay.show { display: flex; animation: fade .25s; }
#result .pics { display: flex; justify-content: center; align-items: flex-end; gap: 10px; }
#result .pics img { height: 150px; }
#result .pics img.lose { height: 90px; opacity: .9; }
#result .score { font-size: 28px; font-weight: 800; margin: 6px 0 0; }

#rotate {
  display: none; position: fixed; inset: 0; z-index: 30;
  background: #2b1d5c; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
#rotate div { font-size: 70px; animation: rot 1.6s ease-in-out infinite; }
#rotate p { font-size: 24px; padding: 0 20px; }
@media (orientation: portrait) {
  body.playing #rotate { display: flex; }
}

/* Điện thoại nằm ngang: menu 2 cột cho gọn */
@media (orientation: landscape) and (max-height: 520px) {
  .hub-wrap { flex-direction: row; max-width: 1000px; gap: 22px; }
  .hero { flex: 0 0 38%; }
  .logo { font-size: 46px; }
  .kids img { height: 150px; }
  .cards { gap: 10px; }
  .card { min-height: 92px; padding: 8px; border-radius: 18px; }
  .card .emo { font-size: 30px; }
  .card img { height: 40px; }
  .card b { font-size: 20px; }
  .card i { font-size: 13px; }
  .panel { padding: 12px 18px; }
  .panel h2 { font-size: 26px; margin-bottom: 6px; }
  .pick img, .vs img { height: 70px; }
  .label { margin: 6px 0 4px; }
  .big-btn { font-size: 24px; padding: 8px; }
  .hint { margin: 6px 0; }
  #result .pics img { height: 76px; }
  #result .pics img.lose { height: 52px; }
  #result .score { font-size: 22px; margin: 0; }
  #result .panel h2 { font-size: 24px; margin-bottom: 2px; }
  #result .big-btn { margin-top: 8px; }
  #result .back { margin-top: 4px; }
  .ref-line { margin-top: 6px; font-size: 15px; }
  .seg { padding: 4px; }
  .seg button { font-size: 18px; padding: 5px 4px; }
  .pick { flex-direction: row; gap: 10px; justify-content: center; padding: 4px; max-width: 200px; }
  .pick img { height: 54px; }
  .label { font-size: 15px; margin: 6px 0 3px; }
  #fb-setup .hint.small { display: none; }
  .legend { font-size: 12.5px; padding: 6px 10px; gap: 2px 10px; }
  .legend .ic { font-size: 16px; flex-basis: 20px; }
  #pause .label { display: none; }
  #fb-setup .back { margin-top: 2px; }
  #fb-setup { padding-top: 6px; padding-bottom: 6px; }
  #fb-setup .panel h2 { font-size: 22px; margin-bottom: 4px; }
  #fb-setup .big-btn { margin-top: 6px; }
  .ref-line { margin-top: 4px; }
  .ref-line img { height: 34px; }
}

@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes pulse { 50% { transform: scale(1.05); } }
@keyframes glow { to { box-shadow: 0 7px 0 #a8355a, 0 0 30px 8px #ffd166; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rot { 50% { transform: rotate(-90deg); } }
