/* Giggleland – custom styles (Tailwind handles layout utilities) */
:root {
  --sky: #4dabf7;
  --ink: #2b2d42;
  --kid-font: "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { font-family: var(--kid-font); color: var(--ink); }
body {
  background: linear-gradient(180deg, #74c0fc 0%, #a5d8ff 45%, #b2f2bb 100%) fixed;
  overscroll-behavior: none;
}
.welcome-bg { background: radial-gradient(circle at 30% 20%, #ffe066 0, transparent 30%), linear-gradient(160deg, #74c0fc, #b197fc 60%, #f783ac); }

.card { background: #fff; border-radius: 28px; box-shadow: 0 10px 0 rgba(0,0,0,.08), 0 18px 40px rgba(0,0,0,.15); }
.topbar { background: rgba(255,255,255,.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 3px solid rgba(255,255,255,.9); }

/* ---- Buttons ---- */
.btn-kid {
  font-family: var(--kid-font); font-weight: 800; font-size: 1.15rem; line-height: 1.2;
  padding: .65rem 1.2rem; border-radius: 18px; border: none; cursor: pointer; color: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.22); transition: transform .08s, box-shadow .08s, filter .15s;
  min-height: 48px; user-select: none; touch-action: manipulation;
}
.btn-kid:hover { filter: brightness(1.07); }
.btn-kid:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn-kid:disabled { filter: grayscale(.8) opacity(.6); cursor: not-allowed; transform: none; }
.btn-sm { font-size: 1rem; padding: .45rem .9rem; min-height: 42px; }
.btn-green { background: #40c057; } .btn-blue { background: #339af0; } .btn-purple { background: #845ef7; }
.btn-orange { background: #fd7e14; } .btn-pink { background: #f06595; } .btn-red { background: #fa5252; }
.btn-white { background: #fff; color: var(--ink); border: 3px solid #e9ecef; }
.btn-gold { background: #fab005; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px; padding: .3rem .8rem;
  font-weight: 800; font-size: 1rem; min-height: 42px; border: none; white-space: nowrap;
}
button.chip { cursor: pointer; }
.chip-white { background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.chip-purple { background: #845ef7; color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.chip-gold { background: #ffd43b; color: #7a4b00; box-shadow: 0 3px 0 rgba(0,0,0,.15); }

.net-dot { width: 12px; height: 12px; border-radius: 50%; background: #adb5bd; display: inline-block; }
.net-dot.on { background: #40c057; box-shadow: 0 0 6px #40c057; }
.net-dot.off { background: #fa5252; }

.input-kid {
  font-family: var(--kid-font); font-size: 1.35rem; font-weight: 700; padding: .5rem .9rem; border-radius: 16px;
  border: 3px solid #dee2e6; outline: none; background: #f8f9fa;
}
.input-kid:focus { border-color: var(--sky); background: #fff; }

.swatch { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px #dee2e6; cursor: pointer; transition: transform .1s; }
.swatch.active { transform: scale(1.18); box-shadow: 0 0 0 3px var(--ink); }

/* ---- Members strip ---- */
.member { position: relative; width: 42px; height: 42px; border-radius: 50%; background: #fff; display: grid; place-items: center; transition: box-shadow .15s; }
.member canvas { width: 38px; height: 38px; }
.member-card { display: flex; align-items: center; gap: .5rem; background: #f8f9fa; border-radius: 18px; padding: .4rem .6rem; font-weight: 800; }
.member-card .member { width: 54px; height: 54px; flex: none; }
.member-card .member canvas { width: 50px; height: 50px; }

/* ---- Stages ---- */
.stage { max-width: min(100%, max(320px, calc((var(--vh100, 100vh) - var(--g-hub, 150px)) * 1.6667))); }
.stage-wide { max-width: min(100%, max(320px, calc((var(--vh100, 100vh) - var(--g-board, 400px)) * 1.935))); }
.stage-canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: pointer; }
.status-line { text-align: center; font-weight: 800; font-size: 1.2rem; color: #5f3dc4; background: #f3f0ff; border-radius: 14px; padding: .35rem .8rem; margin-bottom: .5rem; }

/* ---- Creative ---- */
.tool-panel { background: #fff5f9; border-radius: 20px; padding: .7rem; }
.tool-title { font-weight: 800; color: #c2255c; font-size: 1rem; margin-top: .2rem; }
.tool-btn {
  font-family: var(--kid-font); font-weight: 800; font-size: 1rem; background: #fff; border: 3px solid #fcc2d7;
  border-radius: 14px; padding: .35rem .7rem; min-height: 44px; cursor: pointer; text-align: left; transition: transform .08s;
}
.tool-btn:active { transform: scale(.95); }
.tool-btn.active { background: #f06595; color: #fff; border-color: #f06595; }
.tool-danger { border-color: #ffa8a8; color: #e03131; }
.draw-canvas { background: #fff; border: 4px dashed #fcc2d7; touch-action: none; cursor: crosshair; display: block; }
.dg-banner { background: #fff; border-radius: 14px; padding: .35rem .6rem; font-weight: 800; text-align: center; font-size: 1.05rem; flex: 1; min-width: 0; }
.dg-banner .secret { font-size: 1.5rem; color: #c2255c; display: inline-block; margin-left: .3rem; }
.dg-banner .pattern { font-size: 1.5rem; letter-spacing: .22em; display: inline-block; margin-left: .4rem; color: #5f3dc4; white-space: nowrap; }
/* the Draw & Guess bar right above the board */
.dg-bar { background: #fff0f6; border: 3px solid #fcc2d7; border-radius: 20px; padding: .35rem; margin-bottom: .4rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.dg-top { display: flex; align-items: center; gap: .4rem; flex: 1 1 280px; min-width: 0; }
.dg-timer { font-size: 1.7rem; font-weight: 800; color: #d6336c; background: #fff; border-radius: 14px; min-width: 2.6em; text-align: center; padding: 0 .3rem; }
.dg-timer.low { color: #fa5252; animation: dgPulse .5s ease-in-out infinite alternate; }
@keyframes dgPulse { to { transform: scale(1.12); } }
.dg-modes, .dg-play, .dg-drawer-btns { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; align-items: center; }
.dg-modes { flex: 1 1 auto; }
.dg-play { flex: 1 1 100%; }
@keyframes dgShake { 25% { transform: translateX(-6px) rotate(-6deg); } 75% { transform: translateX(6px) rotate(6deg); } }
.dg-guess { display: flex; gap: .3rem; flex: 1 1 200px; max-width: 360px; }
.dg-scores { display: flex; flex-wrap: wrap; gap: .3rem; }
.dg-score { background: #fff; border-radius: 12px; padding: .1rem .5rem; font-weight: 800; font-size: .95rem; }
.dg-score.me { background: #d3f9d8; }
.draw-wrap { position: relative; }
.dg-cover { position: absolute; inset: 0; z-index: 2; border-radius: 16px; background: rgba(255, 240, 246, .97); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  text-align: center; font-weight: 800; font-size: 1.5rem; color: #a61e4d; cursor: pointer; padding: 1rem; }
.dg-cover-big { font-size: 5rem; line-height: 1.1; }
.dg-cover-word { font-size: 2.6rem; letter-spacing: .08em; }
.dg-cover-small { font-size: 1.1rem; color: #495057; }
.dg-cover .btn-kid { flex: none; }
/* guessers can't draw, so the drawing tools step back */
.dg-guessing #palette { display: none !important; }
.dg-feed { background: #fff; border-radius: 14px; padding: .5rem; height: 180px; overflow-y: auto; font-size: .95rem; }
.dg-feed div { padding: 2px 0; border-bottom: 1px dashed #f1f3f5; }
.dg-feed .good { color: #2b8a3e; font-weight: 800; }
.dg-feed .info { color: #5f3dc4; font-weight: 800; }

/* ---- Math ---- */
.race-problem { text-align: center; margin-top: .8rem; }
.rp-visual { font-size: 2.1rem; line-height: 1.2; min-height: 0; }
.rp-visual .op { font-weight: 800; color: #868e96; margin: 0 .3rem; }
.rp-visual .gone { opacity: .25; text-decoration: line-through; }
.rp-text { font-size: 3.2rem; font-weight: 800; color: #2b8a3e; }
.choice-btn { font-size: 2rem !important; min-height: 72px; }
.choice-btn.right { background: #2f9e44 !important; }
.choice-btn.wrong { background: #e03131 !important; animation: shake .35s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 6rem; font-weight: 800; color: #fff; text-shadow: 0 6px 0 rgba(0,0,0,.25); background: rgba(0,0,0,.25); border-radius: 1rem; }

.market-counter { background: linear-gradient(#fff9db, #ffec99); border-radius: 22px; padding: 1rem; }
.speech { background: #fff; border-radius: 18px; padding: .8rem 1rem; font-size: 1.25rem; font-weight: 700; position: relative; margin-top: .6rem; text-align: center; }
.speech::before { content: ""; position: absolute; top: -14px; left: 50%; margin-left: -10px; border: 10px solid transparent; border-bottom-color: #fff; border-top: 0; }
.speech b { color: #e8590c; }
.tray { min-height: 120px; border: 4px dashed #94d82d; background: #f4fce3; border-radius: 22px; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; padding: .6rem; transition: background .15s; }
.tray.hot { background: #d8f5a2; }
.tray-hint { color: #94d82d; font-weight: 800; font-size: 1.2rem; }
.coin {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem;
  cursor: grab; user-select: none; touch-action: none; box-shadow: 0 4px 0 rgba(0,0,0,.25), inset 0 0 0 4px rgba(255,255,255,.35);
  color: #5c3c00;
}
.coin.small { width: 60px; height: 60px; font-size: 1.05rem; }
.coin-200 { background: radial-gradient(circle, #ffd43b 0 52%, #ced4da 53% 100%); }
.coin-100 { background: radial-gradient(circle, #dee2e6 0 52%, #fcc419 53% 100%); }
.coin-50  { background: radial-gradient(circle at 35% 35%, #ffe066, #f59f00); width: 66px; height: 66px; }
.coin-20  { background: radial-gradient(circle at 35% 35%, #ffe8a1, #e8a317); width: 58px; height: 58px; font-size: 1.05rem; }
.coin-ghost { position: fixed; pointer-events: none; z-index: 100; transform: translate(-50%, -50%) scale(1.15); opacity: .92; }

/* ---- Shop ---- */
.shop-stage { background: radial-gradient(circle at 50% 40%, #fff3bf, #ffd8a8); }
.item-card { background: #fff8f0; border: 3px solid #ffd8a8; border-radius: 22px; padding: .8rem; display: flex; gap: .8rem; align-items: center; }
.item-card.equipped { border-color: #40c057; background: #ebfbee; }
.item-card canvas { width: 92px; height: 92px; flex: none; background: #fff; border-radius: 18px; }

/* ---- Overlays, modals, toasts ---- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(30, 30, 60, .45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.pop-in { animation: popIn .25s cubic-bezier(.2,1.6,.4,1); }
@keyframes popIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.room-code { font-size: 4rem; font-weight: 800; letter-spacing: .25em; text-align: center; color: #845ef7; line-height: 1.1; margin: .2rem 0 .6rem; }
.warn-box { background: #fff4e6; color: #d9480f; border-radius: 14px; padding: .5rem .8rem; font-weight: 700; margin-bottom: .8rem; }

.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #fff; border-radius: 18px; padding: .6rem 1.1rem; font-weight: 800; font-size: 1.1rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: toastIn .25s ease-out; transition: opacity .35s, transform .35s; text-align: center; }
.toast.out { opacity: 0; transform: translateY(12px); }
.toast-good { background: #d3f9d8; color: #2b8a3e; }
.toast-warn { background: #fff4e6; color: #d9480f; }
.toast-coin { background: #fff3bf; color: #a66400; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 640px) {
  .btn-kid { font-size: 1rem; padding: .55rem .9rem; }
  .rp-text { font-size: 2.4rem; }
  .room-code { font-size: 3rem; }
}

/* ---- Roleplay Town ---- */
.prop-btn { font-size: 2.1rem; width: 64px; height: 64px; background: #fff; border: 3px solid #ffc9c9; border-radius: 18px; cursor: pointer; transition: transform .08s; }
.prop-btn:active { transform: scale(.92); }
.prop-btn.selected { border-color: #fa5252; background: #fff5f5; transform: translateY(-4px); box-shadow: 0 6px 0 #ffc9c9; }
.role-btn.taken { opacity: .55; }
.emote-btn { font-family: var(--kid-font); font-weight: 800; font-size: .95rem; background: #fff; border: 3px solid #fcc2d7; border-radius: 12px; min-height: 42px; cursor: pointer; padding: .2rem .4rem; }
.emote-btn:active { transform: scale(.94); }

/* ---- Family save code ---- */
.family-box { background: #edf2ff; border: 3px dashed #bac8ff; border-radius: 22px; padding: .9rem 1rem; }
.fam-code { font-size: 2rem; font-weight: 800; letter-spacing: .08em; color: #4c6ef5; background: #fff; border-radius: 16px; padding: .4rem .9rem; display: inline-block; user-select: all; }


/* ---- Tiko the guide ---- */
.tiko { position: fixed; left: 14px; bottom: 14px; z-index: 45; display: flex; align-items: flex-end; gap: 8px; pointer-events: none; max-width: min(460px, 92vw); }
.tiko-bot { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff; font-size: 2.2rem; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #a5d8ff, #4dabf7); box-shadow: 0 6px 16px rgba(0,0,0,.2); animation: tikoFloat 3s ease-in-out infinite; flex: none; }
.tiko-bot.talk { animation: tikoTalk .35s ease-in-out infinite alternate; }
@keyframes tikoFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes tikoTalk { from { transform: rotate(-6deg) scale(1.02); } to { transform: rotate(6deg) scale(1.06); } }
.tiko-bubble { pointer-events: auto; cursor: pointer; background: #fff; border-radius: 18px 18px 18px 4px; padding: .6rem .9rem; font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); margin-bottom: 28px; animation: popIn .25s cubic-bezier(.2,1.6,.4,1); }

/* ---- Quests & badges ---- */
.quest { display: flex; align-items: center; gap: .7rem; background: #f8f9fa; border-radius: 16px; padding: .55rem .8rem; font-weight: 800; }
.quest.done { background: #d3f9d8; }
.quest .bar { height: 10px; background: #e9ecef; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.quest .bar > div { height: 100%; background: linear-gradient(90deg, #845ef7, #4dabf7); border-radius: 6px; }
.badge-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.badge { background: linear-gradient(#fff9db, #ffec99); border-radius: 18px; padding: .6rem .4rem; text-align: center; font-weight: 800; font-size: .85rem; }
.badge .e { font-size: 2.2rem; display: block; }
.badge.locked { background: #f1f3f5; color: #adb5bd; }
.badge.locked .e { filter: grayscale(1); opacity: .45; }
.badge small { display: block; font-weight: 600; font-size: .72rem; color: #868e96; margin-top: 2px; }
.pet-card { background: #fff8f0; border: 3px solid #ffd8a8; border-radius: 20px; padding: .6rem; text-align: center; }
.pet-card.equipped { border-color: #40c057; background: #ebfbee; }
.pet-card .e { font-size: 2.8rem; display: block; }

.bg-swatch { width: 34px; height: 34px; border-radius: 10px; border: 3px solid #fff; box-shadow: 0 0 0 2px #fcc2d7; cursor: pointer; }
.bg-swatch.active { box-shadow: 0 0 0 3px #f06595; transform: scale(1.1); }
.gallery-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.gallery-grid img { width: 100%; border-radius: 14px; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.1); transition: transform .1s; }
.gallery-grid img:hover { transform: scale(1.03); }

.explain { margin: .8rem auto 0; max-width: 42rem; background: #fff9db; border: 3px solid #ffe066; border-radius: 18px; padding: .6rem 1rem; font-weight: 800; font-size: 1.25rem; color: #7a4b00; }
.pizza-board { width: min(300px, 80vw); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle, #ffd8a8 0 62%, #e8590c 63% 70%, #f59f00 71%); padding: 9%; box-shadow: 0 6px 0 rgba(0,0,0,.12); }
.pizza-base { position: relative; width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle, #ff8787 0 60%, #fa5252 61%); }
.pizza-top { position: absolute; transform: translate(-50%, -50%); font-size: 1.9rem; pointer-events: none; animation: popIn .2s ease-out; }
.rp-visual svg { display: block; margin: 0 auto; }

.age-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.age-btn { font-family: var(--kid-font); font-weight: 800; border-radius: 14px; border: 3px solid #dee2e6; background: #fff; padding: .35rem .2rem; cursor: pointer; font-size: .95rem; }
.age-btn .e { display: block; font-size: 1.5rem; }
.age-btn.active { border-color: #845ef7; background: #f3f0ff; color: #5f3dc4; }
.tiko-voice { pointer-events: auto; width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; background: #fff; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.18); margin-left: -22px; margin-bottom: -4px; flex: none; align-self: flex-end; z-index: 1; }
.tiko-voice.on { background: #d3f9d8; }
/* bigger everything for the youngest players */
.big-mode .btn-kid { font-size: 1.35rem; min-height: 58px; }
.big-mode .chip { font-size: 1.1rem; min-height: 48px; }
.big-mode .tool-btn, .big-mode .emote-btn { font-size: 1.1rem; min-height: 52px; }
.big-mode .prop-btn { width: 76px; height: 76px; font-size: 2.5rem; }

.lang-btn { font-family: var(--kid-font); font-weight: 800; border-radius: 14px; border: 3px solid #dee2e6; background: #fff; padding: .35rem .8rem; cursor: pointer; }
.lang-btn.active { border-color: #339af0; background: #e7f5ff; }

/* ---- world category tabs ---- */
.world-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.world-head h2 { margin: 0 .4rem 0 0; }
.cat-bar { display: flex; flex-wrap: wrap; gap: .45rem; }
.cat-tab { font-family: var(--kid-font); font-weight: 800; font-size: 1.02rem; display: inline-flex; align-items: center; gap: .35rem; border-radius: 16px; border: 3px solid #e9ecef;
  background: #fff; padding: .35rem .8rem; min-height: 46px; cursor: pointer; transition: transform .08s; }
.cat-tab:active { transform: scale(.95); }
.cat-tab .cat-ico { font-size: 1.4rem; }
.cat-tab.active { border-color: #845ef7; background: #f3f0ff; color: #5f3dc4; box-shadow: 0 4px 0 #d0bfff; }
.big-mode .cat-tab { font-size: 1.2rem; min-height: 56px; }

.tq-bar { position: relative; height: 34px; background: #e9ecef; border-radius: 18px; overflow: hidden; }
.tq-fill { height: 100%; width: 0; background: linear-gradient(90deg, #40c057, #94d82d); border-radius: 18px; transition: width .3s; }
.tq-count { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; color: #2b2d42; }

/* ---- Noughts & Crosses ---- */
.ttt-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(420px, 86vw, max(240px, calc(var(--vh100, 100vh) - var(--g-grid, 420px)))); margin: 0 auto; }
.ttt-cell { aspect-ratio: 1; border-radius: 22px; border: 4px solid #a5d8ff; background: #fff; font-size: clamp(3rem, 11vw, 5.5rem); cursor: pointer; box-shadow: 0 5px 0 #d0ebff; }
.ttt-cell:active { transform: scale(.96); }
.ttt-cell.win { background: #fff3bf; border-color: #fab005; animation: popIn .3s; }
/* ---- Memory Match ---- */
.mem-grid { display: grid; gap: 8px; width: min(500px, 94vw, max(280px, calc(var(--vh100, 100vh) - var(--g-grid, 330px)))); margin: 0 auto; }
.mem-card { position: relative; aspect-ratio: 1; border: none; border-radius: 16px; cursor: pointer; perspective: 600px; background: transparent; padding: 0; }
.mem-card span { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 16px; backface-visibility: hidden; transition: transform .35s; font-size: clamp(1.8rem, 6vw, 3rem); box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.mem-back { background: linear-gradient(135deg, #748ffc, #9775fa); color: #fff; }
.mem-face { background: #fff; transform: rotateY(180deg); }
.mem-card.up .mem-back { transform: rotateY(180deg); }
.mem-card.up .mem-face { transform: rotateY(360deg); }
.mem-card.done .mem-face { background: #d3f9d8; }
.mem-card.done[data-owner="1"] .mem-face { background: #e5dbff; }
/* ---- Sea Battle ---- */
.sea-boards { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .sea-boards { grid-template-columns: 1fr 1fr; } }
.sea-grid { display: grid; gap: 4px; background: #1971c2; padding: 8px; border-radius: 16px; width: min(420px, 100%, max(260px, calc(var(--vh100, 100vh) - var(--g-grid, 450px)))); margin: 0 auto; }
.sea-wrap { min-width: 0; }
.sea-cell { aspect-ratio: 1; border: none; border-radius: 6px; background: #4dabf7; font-size: clamp(.9rem, 3vw, 1.5rem); cursor: default; display: grid; place-items: center; }
.sea-cell.target { cursor: crosshair; }
.sea-cell.target:hover { background: #74c0fc; }
.sea-cell.ship { background: #868e96; box-shadow: inset 0 0 0 3px #495057; }
.sea-cell.hit { background: #ffa8a8; }
.sea-cell.sunk { background: #343a40; }
.sea-pass { position: fixed; inset: 0; z-index: 55; background: rgba(25, 113, 194, .96); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.sea-pass.hidden { display: none; }

/* ---- Colouring ---- */
.num-swatch { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px #dee2e6; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); cursor: pointer; }
.num-swatch.active { transform: scale(1.18); box-shadow: 0 0 0 3px #2b2d42; }
.colour-wrap { width: min(640px, 94vw, max(320px, calc((var(--vh100, 100vh) - var(--g-grid, 440px)) * 1.333))); margin: 0 auto; background: #fff; border-radius: 18px; overflow: hidden; border: 4px dashed #fcc2d7; }
.colour-svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.colour-svg > * { cursor: pointer; }
.colour-num { font: 800 18px "Baloo 2", sans-serif; fill: #495057; pointer-events: none; }
/* ---- Music Maker ---- */
.music-grid { display: grid; grid-template-columns: 52px repeat(8, minmax(0, 1fr)); gap: 5px; width: min(720px, 100%, max(320px, calc((var(--vh100, 100vh) - var(--g-grid, 450px)) * 1.39))); margin: 0 auto; }
.music-label { display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; color: #c2255c; background: #fff0f6; border-radius: 10px; }
.music-label.drum { color: #5f3dc4; background: #f3f0ff; font-size: 1.3rem; }
.music-cell { aspect-ratio: 1.3; border: none; border-radius: 10px; background: #f1f3f5; cursor: pointer; transition: transform .06s; }
.music-cell:nth-of-type(9n+6), .music-cell:nth-of-type(9n+7), .music-cell:nth-of-type(9n+8), .music-cell:nth-of-type(9n+9) { background: #e9ecef; }
.music-cell.ghost { background: #ffe066 !important; box-shadow: inset 0 0 0 3px #fab005; }
.music-cell.on { background: #f06595 !important; }
.music-cell.drum.on { background: #845ef7 !important; }
.music-cell.now { transform: scale(1.08); box-shadow: 0 0 0 3px #4dabf7; }
/* ---- Pixel Art ---- */
.pixel-area { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-items: flex-start; }
.pixel-grid { display: grid; gap: 2px; background: #dee2e6; padding: 4px; border-radius: 12px; width: min(460px, 92vw, max(260px, calc(var(--vh100, 100vh) - var(--g-grid, 430px)))); touch-action: none; user-select: none; }
.pixel-cell { aspect-ratio: 1; background: #e9ecef; border-radius: 3px; cursor: pointer; }
.pixel-side { width: 150px; }
.pixel-preview { display: grid; gap: 1px; background: #dee2e6; padding: 3px; border-radius: 10px; }
.pixel-preview div { aspect-ratio: 1; }


/* =====================================================================
   BIG & FUN – phones and tablets. Numbers are chosen so the board fills the screen.
   Sideways: the top bar becomes a rail of big buttons down the left edge.
   Sideways phones: the game board on the left, its controls in a column on the right.
   ===================================================================== */
.tap-spark { position: fixed; z-index: 200; pointer-events: none; font-size: 22px; animation: spark .5s ease-out forwards; }
@keyframes spark { from { transform: translate(-50%, -50%) scale(.5); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(120deg); opacity: 0; } }
.confetti { position: fixed; top: -60px; z-index: 200; pointer-events: none; animation: confettiFall 2.5s ease-in forwards; }
@keyframes confettiFall { to { transform: translateY(115vh) rotate(540deg); } }
#modalEmoji { animation: bigBounce .7s cubic-bezier(.2,1.6,.4,1) 1; display: inline-block; }
@keyframes bigBounce { 0% { transform: scale(.2) rotate(-20deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1); } }
.cat-tab.active .cat-ico { display: inline-block; animation: icoHop 1.1s ease-in-out infinite; }
@keyframes icoHop { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-5px) scale(1.2) rotate(-6deg); } }
.btn-kid, .cat-tab, .chip, .tool-btn { transition: transform .12s cubic-bezier(.2,1.8,.4,1), box-shadow .08s, filter .15s; }
.btn-kid:active, button.chip:active, .cat-tab:active { transform: scale(.9); }
#modalCard { max-height: 94vh; overflow-y: auto; }
@media (prefers-reduced-motion: reduce) { .cat-tab.active .cat-ico, #modalEmoji { animation: none; } }

/* ---- every phone & tablet: big touch targets ---- */
@media (orientation: landscape) and (max-height: 860px), (orientation: portrait) and (max-width: 1000px) {
  html { font-size: 18px; }
  .btn-kid { font-size: 1.3rem; min-height: 62px; border-radius: 20px; }
  .btn-sm, .lvl-btn { font-size: 1.15rem; min-height: 54px; }
  .chip { font-size: 1.15rem; min-height: 54px; }
  .cat-bar, .lvl-row { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
  .cat-bar::-webkit-scrollbar, .lvl-row::-webkit-scrollbar { display: none; }
  .cat-tab, .lvl-btn { flex: none; }
  .cat-tab { font-size: 1.2rem; min-height: 60px; padding: .4rem 1rem; }
  .cat-tab .cat-ico { font-size: 1.9rem; }
  .status-line { font-size: 1.3rem; }
  .tool-btn, .emote-btn { font-size: 1.2rem; min-height: 56px; }
  .swatch { width: 54px; height: 54px; }
  .bg-swatch { width: 48px; height: 48px; }
  .prop-btn { width: 76px; height: 76px; font-size: 2.6rem; }
  .tiko-bot { width: 78px; height: 78px; font-size: 2.7rem; }
  .tiko-voice { width: 48px; height: 48px; font-size: 1.4rem; }
  .tiko-bubble { font-size: 1.3rem; }
  .toast { font-size: 1.4rem; }
  .choice-btn { font-size: 2.6rem !important; min-height: 92px; }
  .rp-text { font-size: 3.6rem; }
  input[type="range"] { height: 34px; }
  #hdrAvatar { width: 3rem; height: 3rem; }
}

/* ---- sideways: rail of big buttons, board as large as the screen allows ---- */
@media (orientation: landscape) and (max-height: 860px) {
  :root { --rail: 104px; --g-hub: 16px; --g-board: 352px; --g-grid: 368px; }
  #topbar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail); border-bottom: 0; border-right: 3px solid rgba(255,255,255,.9); overflow-y: auto; scrollbar-width: none; padding-left: env(safe-area-inset-left); box-sizing: content-box; }
  #topbar::-webkit-scrollbar { display: none; }
  #topbar > div { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; padding: 6px 6px 96px; }
  #topbar .chip { flex-direction: column; justify-content: center; gap: 0; width: 100%; min-height: 76px; border-radius: 20px; padding: .2rem; font-size: 2.1rem; line-height: 1.05; white-space: normal; text-align: center; }
  #topbar .chip span { display: inline; font-size: .85rem; line-height: 1.05; }
  #topbar #hdrCoins, #topbar #hdrQuests, #topbar #hdrFriends { font-size: 1.05rem; }
  #topbar .flex-1, #netDot { display: none; }
  #membersStrip { flex-direction: column; align-items: center; }
  #btnHome { order: -3; }
  #app { padding-left: calc(var(--rail) + env(safe-area-inset-left) + 8px); padding-right: 8px; padding-bottom: 8px; }
  .screen .card { margin-top: 6px; max-width: none; padding: 8px; border-radius: 20px; }
  .world-head h2 { display: none; }
  .world-head { margin-bottom: 4px; }
  .cat-panel > p.font-extrabold:first-child { display: none; }
  .screen .stage { margin-top: 6px; }
  #hubHint { display: none; }
  .tiko { left: calc(env(safe-area-inset-left) + 13px); bottom: 8px; }
  .tiko-voice { display: none; }
  .tiko-bubble { margin-bottom: 8px; margin-left: 8px; pointer-events: none; }
  .status-line { padding: .2rem .8rem; margin-bottom: .3rem; }
  .cat-panel > .justify-center, .cat-panel .mt-3.justify-center { margin-top: .4rem; }
  .cat-panel > .justify-center { flex-wrap: nowrap !important; }
  .cat-panel:has(> .justify-center:nth-last-child(2):not(:empty)) { --g-board: 425px; }
  .draw-grid { grid-template-columns: 200px minmax(0, 1fr) !important; }
  .draw-grid > :last-child { grid-column: 1 / -1; }
  .draw-wrap { max-width: calc((var(--vh100, 100vh) - 185px - var(--dgbar, 0px)) * 1.5); margin: 0 auto; }
  #palette { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start !important; scrollbar-width: none; padding: 4px; }
  .cat-panel > .flex-wrap:not(.justify-center) { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .cat-panel > .flex-wrap:not(.justify-center) > * { flex: none; }
}

/* ---- sideways phones: board left, controls in a column on the right ---- */
@media (orientation: landscape) and (max-height: 720px) {
  html { font-size: 16px; }
  :root { --rail: 78px; --side: clamp(150px, 19vw, 210px); --g-hub: 12px; --g-board: 16px; --g-grid: 16px; }
  #topbar .chip { min-height: 56px; font-size: 1.6rem; }
  .tiko-bubble { font-size: 1.05rem; max-width: 280px; }
  #topbar .chip span { font-size: .72rem; }
  #topbar .chip-me { display: none; } .friends-label { display: none !important; }
  #btnMyHome { order: 5; }
  .tiko-bot { width: 64px; height: 64px; font-size: 2.2rem; }
  .tiko { left: calc(env(safe-area-inset-left) + 10px); bottom: 4px; }
  .screen .world-card { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); column-gap: 8px; align-items: start; padding: 6px; margin-top: 4px; }
  .card > .cat-panel:not(.hidden) { display: contents; }
  .cat-panel:has(> .justify-center:nth-last-child(2):not(:empty)) { --g-board: 16px; }
  .card > .world-head, .card > .cat-panel > * { grid-column: 2; min-width: 0; order: 4; }
  .card > .world-head { order: 5; margin: 0; }
  .card > .cat-panel > .status-line { order: 1; font-size: 1.02rem; line-height: 1.2; }
  .card > .cat-panel > .justify-center, .card > .cat-panel > .text-center { order: 2; flex-wrap: wrap !important; margin-top: 0; margin-bottom: 6px; }
  .card > .cat-panel > .lvl-row { order: 3; }
  .card > .cat-panel > .flex-wrap:not(.justify-center):not(.lvl-row) { flex-wrap: wrap !important; overflow: visible; }
  .card > .cat-panel > .flex-wrap:not(.justify-center):not(.lvl-row) > * { flex: 0 1 auto; max-width: 100%; }
  .card > .cat-panel > .stage-wide, .card > .cat-panel > .board-box, .card > .cat-panel > .colour-wrap, .card > .cat-panel > .music-grid, .card > .cat-panel > .pixel-area,
  .card > .cat-panel > .sea-boards, .card > .cat-panel > .ttt-board, .card > .cat-panel > .mem-grid, .card > .cat-panel > .tq-mapview, .card > .cat-panel > .tq-playview,
  .card > .cat-panel > .egg-stage, .card > .cat-panel > .grid, .card > .cat-panel > #mathRace, .card > .cat-panel > #mathPizza, .card > .cat-panel > #mathMarket {
    grid-column: 1; grid-row: 1 / span 30; position: sticky; top: 4px; margin-inline: auto; width: 100%;
  }
  .card > .cat-panel > .ttt-board { width: min(100%, calc(var(--vh100, 100vh) - 16px)); }
  .card > .cat-panel > .mem-grid { width: min(100%, calc((var(--vh100, 100vh) - 16px) * 1.5)); }
  .card > .cat-panel > .colour-wrap { width: min(100%, calc((var(--vh100, 100vh) - 16px) * 1.333)); }
  .card > .cat-panel > .music-grid { width: min(100%, calc((var(--vh100, 100vh) - 16px) * 1.39)); }
  .cat-tab > span:not(.cat-ico) { display: none; }
  .cat-tab { min-height: 54px; padding: .2rem .55rem; }
  .cat-bar { flex-wrap: wrap !important; overflow: visible; }
  .btn-kid { font-size: 1.05rem; min-height: 52px; padding: .35rem .6rem; flex: 1 1 auto; }
  .btn-sm, .lvl-btn { font-size: 1rem; min-height: 48px; }
  .lvl-btn { flex: none; }
  .chip { font-size: 1rem; min-height: 44px; }
  .swatch { width: 44px; height: 44px; }
  .choice-btn { font-size: 1.9rem !important; min-height: 64px; }
  .rp-text { font-size: 2.3rem; }
  /* Draw & Guess: board left, tools right */
  .card > .cat-panel > .draw-grid { display: contents; }
  .draw-grid > * { grid-column: 2; min-width: 0; order: 6; }
  .draw-grid > .order-1 { grid-column: 1; grid-row: 1 / span 30; position: sticky; top: 4px; }
  .draw-grid .tool-panel { padding: .4rem; }
  #palette { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start !important; scrollbar-width: none; padding: 4px; margin-bottom: 2px; }
  .draw-wrap { max-width: calc((var(--vh100, 100vh) - 84px - var(--dgbar, 0px)) * 1.5); margin: 0 auto; }
  /* Roleplay Town */
  #screen-roleplay .card > .grid { grid-template-columns: minmax(0, 1fr) var(--side); }
  #screen-roleplay h2, #screen-roleplay .card > :first-child > .chip, #screen-roleplay .card > :first-child > .flex-1 { display: none; }
  #rpScenes { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  #rpScenes .btn-kid { flex: none; }
  #screen-roleplay .status-line { font-size: 1rem; }
}

/* ---- upright phones: one row of big icons, so the game gets the screen ---- */
@media (orientation: portrait) and (max-width: 640px) {
  #topbar > div { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding: 6px; gap: 5px; }
  #topbar > div::-webkit-scrollbar { display: none; }
  #topbar .chip { flex: none; min-height: 58px; font-size: 1.7rem; padding: .2rem .55rem; }
  #topbar .chip-me, .friends-label, #netDot, #topbar .flex-1, #hdrRoom { display: none; }
  #topbar #hdrCoins, #topbar #hdrQuests { font-size: 1.1rem; }
  .chip { white-space: normal; max-width: 100%; }
  .cat-panel > .flex-wrap:not(.justify-center) { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .cat-panel > .flex-wrap:not(.justify-center) > * { flex: none; }
  .cat-panel > p.font-extrabold:first-child, .world-head h2 { display: none; }
}

/* ---- Adventure Park ---- */
.obby-wrap { position: relative; }
.obby-pad { display: flex; gap: 10px; margin-top: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.obby-btn { font-family: var(--kid-font); font-weight: 800; color: #fff; border: 4px solid #fff; border-radius: 50%; width: 92px; height: 92px; font-size: 2.4rem; background: #339af0; box-shadow: 0 6px 0 rgba(0,0,0,.2); touch-action: none; cursor: pointer; }
.obby-btn:active { transform: translateY(4px) scale(.95); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.obby-jump { width: 150px; border-radius: 46px; background: #40c057; font-size: 1.5rem; }
.tyc-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 10px; }
.tyc-card { font-family: var(--kid-font); font-weight: 800; background: #f1f3f5; border: 4px solid #dee2e6; border-radius: 20px; padding: .5rem; cursor: pointer; display: grid; justify-items: center; opacity: .75; }
.tyc-card.can { background: #ebfbee; border-color: #40c057; opacity: 1; animation: tycGlow 1.4s infinite; }
@keyframes tycGlow { 50% { box-shadow: 0 0 0 5px rgba(64,192,87,.3); } }
.tyc-card:active { transform: scale(.94); }
.tyc-e { font-size: 3rem; line-height: 1.1; } .tyc-n { font-size: 1.05rem; } .tyc-i { font-size: 1rem; color: #2b8a3e; }
.egg-stage { display: grid; place-items: center; min-height: 230px; border-radius: 24px; background: radial-gradient(circle, #fff9db, #ffd8a8); overflow: hidden; }
.egg-big { font-size: 9rem; line-height: 1; }
.egg-big.shake { animation: eggShake .16s linear infinite; }
.egg-big.reveal { animation: bigBounce .7s cubic-bezier(.2,1.6,.4,1); }
@keyframes eggShake { 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg) scale(1.08); } }
.egg-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); margin-top: 6px; }
.egg-pet { font-family: var(--kid-font); font-weight: 800; background: #f1f3f5; border: 3px solid #e9ecef; border-radius: 18px; padding: .4rem .2rem; display: grid; justify-items: center; color: #adb5bd; }
.egg-pet .e { font-size: 2.6rem; line-height: 1.1; }
.egg-pet.got { background: #fff9db; border-color: #ffe066; color: #5c3c00; cursor: pointer; }
.egg-pet.on { border-color: #40c057; background: #ebfbee; }
@media (orientation: landscape) and (max-height: 860px) {
  .obby-pad { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; pointer-events: none; }
  .obby-btn { pointer-events: auto; background: rgba(51,154,240,.72); }
  .obby-jump { background: rgba(64,192,87,.78); }
  .obby-wrap { --g-board: 270px; }
}
@media (orientation: landscape) and (max-height: 720px) {
  .obby-wrap { width: 100%; --g-board: 16px; }
  .obby-btn { width: 74px; height: 74px; font-size: 2rem; }
  .obby-jump { width: 120px; border-radius: 38px; font-size: 1.2rem; }
  .egg-stage { min-height: calc(var(--vh100, 100vh) - 20px); }
  .tyc-grid { grid-template-columns: 1fr; }
  .tyc-e { font-size: 2.2rem; }
}

/* ---- fill the sideways tablet: centre the board in the free height ---- */
@media (orientation: landscape) and (max-height: 720px) {
  .screen .world-card { min-height: calc(var(--vh100, 100vh) - 14px); }
  .card > .cat-panel > .board-box, .card > .cat-panel > .obby-wrap, .card > .cat-panel > .stage-wide, .card > .cat-panel > .sea-boards, .card > .cat-panel > .ttt-board,
  .card > .cat-panel > .mem-grid, .card > .cat-panel > .colour-wrap, .card > .cat-panel > .music-grid, .card > .cat-panel > .pixel-area, .draw-grid > .order-1 {
    align-self: center; top: 8px;
  }
}
/* ---- wardrobe & friends ---- */
.look-row { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.look-opt { font-family: var(--kid-font); font-weight: 800; font-size: .95rem; background: #fff8f0; border: 4px solid #ffe8cc; border-radius: 18px; padding: .3rem; display: grid; justify-items: center; cursor: pointer; }
.look-opt canvas { width: 100%; max-width: 110px; height: auto; }
.look-opt.on { border-color: #40c057; background: #ebfbee; }
.look-opt:active { transform: scale(.94); }
.friend-row { display: flex; align-items: center; gap: .5rem; background: #f8f9fa; border-radius: 18px; padding: .35rem .6rem; font-size: 1.2rem; flex-wrap: wrap; }
.friend-row canvas { width: 56px; height: 56px; }
.friend-x { font-size: 1.2rem; width: 44px; height: 44px; color: #adb5bd; }
@media (orientation: landscape) and (max-height: 720px) { #welcome { align-items: flex-start; overflow-y: auto; } }

/* ---- Avatar Creator (Nov 2026) ---- */
.creator { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(circle at 20% 15%, #ffe066 0, transparent 28%), radial-gradient(circle at 85% 80%, #63e6be 0, transparent 30%), linear-gradient(150deg, #74c0fc, #b197fc 55%, #f783ac); }
.creator-card { background: #fff; border-radius: 32px; box-shadow: 0 12px 0 rgba(0,0,0,.1), 0 24px 60px rgba(0,0,0,.2);
  width: min(1100px, 100%); height: min(760px, calc(var(--vh100, 100vh) - 24px)); display: grid; grid-template-columns: minmax(220px, 38%) 1fr; overflow: hidden; }
.creator-stage { background: linear-gradient(180deg, #e7f5ff, #fff0f6); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; gap: 8px; min-height: 0; }
.creator-stage canvas { width: 100%; max-width: 360px; height: auto; max-height: calc(100% - 60px); object-fit: contain; }
.creator-side { display: flex; flex-direction: column; padding: 16px 18px; min-height: 0; }
.cr-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 6px; flex-shrink: 0; }
.cr-tab { flex: 1 0 auto; min-width: 74px; display: grid; justify-items: center; font-family: var(--kid-font); font-weight: 800; font-size: .95rem;
  background: #f1f3f5; border-radius: 18px; padding: .35rem .5rem; border: 3px solid transparent; cursor: pointer; transition: transform .12s; }
.cr-tab-e { font-size: 1.8rem; line-height: 1.1; }
.cr-tab.on { background: #fff0f6; border-color: #f06595; color: #c2255c; transform: translateY(-2px); }
.cr-tab:active { transform: scale(.92); }
.cr-body { flex: 1 1 0; overflow-y: auto; padding: 2px 4px 8px; min-height: 0; }
.cr-title { font-weight: 800; color: #c2255c; font-size: 1.1rem; margin: .6rem 0 .3rem; }
.cr-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.cr-opt { font-family: var(--kid-font); font-weight: 800; font-size: .85rem; background: #f8f9fa; border: 4px solid #e9ecef; border-radius: 18px; padding: .25rem;
  display: grid; justify-items: center; cursor: pointer; transition: transform .12s cubic-bezier(.2,1.8,.4,1); }
.cr-opt canvas { width: 100%; max-width: 96px; height: auto; }
.cr-opt.on { border-color: #40c057; background: #ebfbee; transform: scale(1.04); }
.cr-opt:active { transform: scale(.92); }
.cr-dots { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-note { background: #fff9db; border-radius: 16px; padding: .6rem .8rem; font-weight: 700; color: #866100; margin-top: .4rem; }
@media (max-width: 700px) {
  .creator-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .creator-stage { flex-direction: row; padding: 6px; }
  .creator-stage canvas { width: auto; height: 210px; }
  .creator-stage > div { flex-direction: column; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .creator-card { grid-template-columns: 34% 1fr; }
}
#crDone { flex: none; }

/* ---- Brain Lab & Fun Arcade (Nov 2026) ---- */
@keyframes labShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.lab-shake { animation: labShake .4s; }
@keyframes labPop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.coder-pal { display: flex; gap: 10px; justify-content: center; margin: .3rem 0; }
.coder-key { width: 72px; height: 72px; font-size: 2.4rem; border-radius: 20px; background: #fff; border: 4px solid #96f2d7; box-shadow: 0 5px 0 #63e6be; cursor: pointer; }
.coder-key:active { transform: translateY(4px); box-shadow: 0 1px 0 #63e6be; }
.coder-prog { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; background: #e6fcf5; border-radius: 20px; padding: 8px; margin-top: 6px; }
.coder-slot { position: relative; width: 60px; height: 60px; border-radius: 16px; border: 3px dashed #96f2d7; color: #96f2d7; font-weight: 800; font-size: 1.1rem; background: transparent; }
.coder-slot.full { border: 3px solid #20c997; background: #fff; font-size: 2rem; color: inherit; animation: labPop .25s; cursor: pointer; }
.coder-slot.now { background: #fff3bf; border-color: #fab005; transform: scale(1.12); }
.coder-rep { position: absolute; right: -6px; top: -8px; background: #845ef7; color: #fff; border-radius: 999px; font-size: .9rem; padding: 0 .4rem; }
.sdk-board { display: grid; gap: 0; width: min(100%, 460px, calc((var(--vh100, 100vh) - 330px))); min-width: 260px; aspect-ratio: 1; margin: 0 auto; border: 5px solid #5c7cfa; border-radius: 18px; overflow: hidden; background: #fff; }
.sdk-cell { border: 1px solid #dbe4ff; font-size: clamp(1.6rem, 6vw, 2.8rem); background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #364fc7; }
.sdk-board.six .sdk-cell { font-size: clamp(1.2rem, 4.5vw, 2.1rem); }
.sdk-cell.tint { background: #f3f0ff; }
.sdk-cell.given { cursor: default; filter: saturate(.8); color: #1b1b2f; }
.sdk-cell.edge-r { border-right: 4px solid #5c7cfa; }
.sdk-cell.edge-b { border-bottom: 4px solid #5c7cfa; }
.sdk-cell.bad { background: #ffe3e3 !important; }
.sdk-cell.pop { animation: labPop .3s; }
.sdk-pal { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sdk-pick { width: 64px; height: 64px; font-size: 2.2rem; font-weight: 800; border-radius: 18px; background: #fff; border: 4px solid #e9ecef; cursor: pointer; color: #364fc7; }
.sdk-pick.on { border-color: #845ef7; background: #f3f0ff; transform: scale(1.1); }
.spell-pic { font-size: clamp(5rem, 16vw, 8rem); text-align: center; line-height: 1.2; }
.spell-pic.pop { animation: labPop .4s; }
.spell-slots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: .4rem 0 1rem; }
.spell-slot { width: 58px; height: 66px; border-bottom: 6px solid #fab005; font-size: 2.6rem; font-weight: 800; text-align: center; color: #e67700; background: #fff9db; border-radius: 12px 12px 4px 4px; }
.spell-slot.on { animation: labPop .25s; }
.spell-slots.win .spell-slot { background: #d3f9d8; border-color: #40c057; color: #2b8a3e; }
.spell-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.spell-tile { width: 64px; height: 64px; font-size: 2.2rem; font-weight: 800; border-radius: 16px; background: #fff; border: 4px solid #ffd43b; box-shadow: 0 5px 0 #fab005; cursor: pointer; color: #2b2d42; }
.spell-tile.used { visibility: hidden; }
.spell-tile.bad { background: #ffe3e3; border-color: #fa5252; }
.quiz-topics { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.quiz-topic { display: grid; justify-items: center; gap: 2px; padding: 1rem .5rem; border-radius: 22px; background: linear-gradient(160deg, #e7f5ff, #f3f0ff); border: 4px solid #d0ebff; font-weight: 800; font-size: 1.2rem; cursor: pointer; transition: transform .12s; }
.quiz-topic:active { transform: scale(.94); }
.quiz-topic .e { font-size: 3.2rem; }
.quiz-topic small { color: #868e96; font-size: .9rem; }
.quiz-bar { height: 14px; background: #e9ecef; border-radius: 999px; overflow: hidden; margin-bottom: .6rem; }
.quiz-bar > div { height: 100%; background: linear-gradient(90deg, #4dabf7, #845ef7); transition: width .4s; }
.quiz-q { font-size: clamp(1.3rem, 3.5vw, 2rem); font-weight: 800; text-align: center; margin: .4rem 0 .8rem; }
.quiz-ans { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); max-width: 820px; margin: 0 auto; }
.quiz-opt { font-size: 1.3rem; min-height: 64px; }
.quiz-fact { max-width: 820px; margin: .9rem auto 0; background: #fff9db; border-radius: 18px; padding: .8rem 1rem; font-size: 1.15rem; text-align: center; animation: labPop .3s; }
.snake-pad { display: flex; gap: 6px; }
.snake-key { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; background: #fff; border: 4px solid #b2f2bb; box-shadow: 0 5px 0 #8ce99a; touch-action: none; }
.snake-key:active { transform: translateY(4px); box-shadow: 0 1px 0 #8ce99a; }
.simon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: min(100%, 440px, calc(var(--vh100, 100vh) - 300px)); min-width: 240px; margin: .5rem auto 0; }
.simon-pad { aspect-ratio: 1; border-radius: 30px; font-size: clamp(3rem, 10vw, 5.5rem); background: var(--c); opacity: .7; border: 6px solid rgba(255,255,255,.7); box-shadow: 0 8px 0 rgba(0,0,0,.18); transition: opacity .1s, transform .1s, filter .1s; touch-action: none; }
.simon-pad.lit { opacity: 1; transform: scale(1.06); filter: brightness(1.15) drop-shadow(0 0 18px var(--c)); }
.simon-pad.hint { opacity: 1; outline: 6px dashed #fff; }

@media (orientation: landscape) and (max-height: 860px) {
  .card > .cat-panel > .sdk-board, .card > .cat-panel > .simon-grid, .card > .cat-panel > .lab-main { grid-column: 1; grid-row: 1 / span 30; position: sticky; top: 4px; margin-inline: auto; }
  .card > .cat-panel > .lab-main { width: 100%; }
  .sdk-board, .simon-grid { width: min(100%, calc(var(--vh100, 100vh) - 40px)); }
  .coder-key { width: 60px; height: 60px; font-size: 2rem; }
  .coder-slot { width: 52px; height: 52px; }
}
@media (orientation: landscape) and (max-height: 860px) {
  .card > .cat-panel > .lab-main:not(.quiz-topics) { min-height: calc(var(--vh100, 100vh) - 60px); display: flex; flex-direction: column; justify-content: center; }
}
.quiz-opt { background: #fff; border: 4px solid #d0ebff; border-radius: 20px; box-shadow: 0 5px 0 #a5d8ff; font-weight: 800; padding: .5rem .8rem; font-size: 1.3rem !important; cursor: pointer; }
.quiz-opt:active { transform: translateY(3px); box-shadow: 0 2px 0 #a5d8ff; }
.quiz-opt.right { background: #40c057; border-color: #2f9e44; color: #fff; box-shadow: 0 5px 0 #2b8a3e; }
.quiz-opt.wrong { background: #fa5252; border-color: #e03131; color: #fff; box-shadow: 0 5px 0 #c92a2a; }
@media (orientation: landscape) and (max-height: 860px) {
  .snake-pad { flex-wrap: wrap; justify-content: center; }
  .snake-key { width: 54px; height: 54px; font-size: 1.6rem; }
}

/* ---- Tablets (Nov 2026): wide boards use the whole width, buttons packed underneath ---- */
@media (orientation: landscape) and (max-height: 720px) {
  .screen .world-card.wide { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 6px; }
  .world-card.wide > .cat-panel > * { order: 3; margin: 0 !important; flex: 0 1 auto; min-width: 0; }
  .world-card.wide > .cat-panel > .wide-board {
    order: 0; flex: 0 0 100%; position: relative; margin: 0 auto !important;
    max-width: min(100%, calc((var(--vh100, 100vh) - 150px) * var(--ratio, 1.9))) !important;
  }
  .world-card.wide > .cat-panel > .wide-board canvas { width: 100%; height: auto; }
  .world-card.wide > .cat-panel > .status-line { order: 1; flex: 1 1 260px; font-size: 1.15rem; padding: .35rem .7rem; }
  .world-card.wide > .cat-panel > .justify-center, .world-card.wide > .cat-panel > .text-center { order: 2; flex-wrap: nowrap !important; }
  .world-card.wide > .cat-panel > .justify-center .btn-kid { flex: 0 0 auto; }
  .world-card.wide > .cat-panel > .lvl-row, .world-card.wide > .cat-panel > .flex-wrap:not(.justify-center) { order: 3; flex: 1 1 280px; flex-wrap: nowrap !important; overflow-x: auto; }
  .world-card.wide > .world-head { order: 4; flex: 1 1 auto; margin: 0; }
  .world-card.wide > .world-head .cat-bar { flex-wrap: nowrap !important; overflow-x: auto; padding-bottom: 0; }
  .world-card.wide > .cat-panel > .obby-wrap { order: 0; flex: 0 0 100%; }
}

/* ---- Wide-board games only: on a phone/tablet held upright we ask to turn it (body.need-landscape is set by TPPlatform.orient) ---- */
.rotate-me { display: none; }
@media (orientation: portrait) and (pointer: coarse), (orientation: portrait) and (max-width: 700px) {
  body.need-landscape .rotate-me { display: flex; position: fixed; inset: 0; z-index: 1000; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; text-align: center; padding: 2rem;
    background: linear-gradient(160deg, #5b4bff, #b14bff 60%, #ff6fae); color: #fff; font-weight: 800; font-size: 2rem; line-height: 1.2; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
  .rotate-me .tab { width: 120px; height: 180px; border: 10px solid #fff; border-radius: 22px; background: rgba(255,255,255,.25); animation: turnMe 2.4s ease-in-out infinite; display: grid; place-items: center; font-size: 3rem; }
  .rotate-me small { font-size: 1.1rem; opacity: .9; font-weight: 700; }
  .rotate-me .rot-back { margin-top: .6rem; padding: .7rem 1.6rem; border-radius: 999px; border: 2px solid rgba(255,255,255,.7); background: rgba(255,255,255,.18); color: #fff; font: 800 1.1rem var(--kid-font); cursor: pointer; }
  body.need-landscape { overflow: hidden; }
}
@keyframes turnMe { 0%, 25% { transform: rotate(0deg); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
@media (orientation: landscape) and (max-height: 720px) {
  .world-card.wide > .cat-panel > .wide-board { max-width: min(100%, calc((var(--vh100, 100vh) - var(--gap, 152px)) * var(--ratio, 1.9))) !important; }
  .world-card.wide > .cat-panel > .status-line { flex: 1 1 180px; font-size: 1.05rem; line-height: 1.15; }
  .world-card.wide .btn-kid { font-size: 1.05rem; min-height: 50px; padding: .3rem .75rem; border-radius: 16px; }
  .world-card.wide .lvl-btn { min-height: 50px; }
  .world-card.wide > .cat-panel > .flex-wrap:not(.justify-center):not(.lvl-row) { flex: 0 1 auto; }
  .world-card.wide > .cat-panel > .lvl-row { flex: 1 1 160px; }
  .world-card.wide > .world-head { flex: 0 0 auto; max-width: 100%; }
  .world-card.wide .cat-tab > span:not(.cat-ico) { display: none; }
  .world-card.wide .cat-tab { min-height: 50px; padding: .2rem .5rem; }
  .world-card.wide .chip { min-height: 46px; font-size: 1rem; }
}
@media (orientation: landscape) and (max-height: 720px) {
  .world-card.wide #pzName { display: none; }
  .world-card.wide > .cat-panel > .lvl-row.flex-wrap:not(.justify-center) { flex: 1 1 120px; }
  .world-card.wide .chip { padding: .2rem .6rem; }
  .world-card.wide .cat-tab { min-width: 52px; justify-content: center; }
  .world-card.wide .cat-tab .cat-ico { font-size: 1.7rem; }
}
@media (orientation: landscape) and (max-height: 720px) {
  .world-card.wide > .cat-panel > .flex-wrap:not(.justify-center):not(.lvl-row) { flex: 1 1 160px; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  .world-card.wide > .cat-panel > .flex-wrap:not(.justify-center) > * { flex: none; }
}

@media (orientation: landscape) and (max-height: 720px) {
  .coder-title { display: none; }
  .coder-pal { gap: 6px; }
  .coder-key { width: 50px; height: 50px; font-size: 1.7rem; border-radius: 14px; }
  .coder-prog { gap: 5px; padding: 6px; }
  .coder-slot { width: 44px; height: 44px; font-size: .9rem; border-radius: 12px; }
  .coder-slot.full { font-size: 1.6rem; }
}

@media (orientation: landscape) and (max-height: 720px) {
  .card > .cat-panel > .board-box { align-self: start; }
  .coder-ctl { flex-wrap: nowrap !important; }
  .coder-ctl .btn-kid { flex: 1 1 0; min-width: 0; padding-inline: .3rem; }
  .coder-ctl .btn-kid:first-child { flex: 2 1 0; }
}

@media (orientation: landscape) and (max-height: 720px) {
  .card > .cat-panel > .sdk-pal { order: 1; margin-bottom: 6px; }
  .sdk-tip { display: none; }
  .sdk-pick { width: 56px; height: 56px; font-size: 2rem; }
}
.creator-card { grid-template-columns: minmax(200px, 36%) minmax(0, 1fr); }
.creator-side { min-width: 0; }
@media (max-height: 560px) and (orientation: landscape) {
  .creator-side { padding: 10px 12px; }
  .creator-side h2 { font-size: 1.4rem; }
  .cr-tab { min-width: 64px; font-size: .85rem; padding: .2rem .4rem; }
  .cr-tab-e { font-size: 1.5rem; }
}
/* Draw & Guess on sideways tablets: the bar + board start at the top, so the whole board is on screen */
@media (orientation: landscape) and (max-height: 720px) {
  .draw-grid > .order-1 { align-self: start !important; top: 4px; }
  .draw-grid > .dg-bar { order: 0; grid-column: 2; flex-direction: column; flex-wrap: nowrap; align-items: stretch; padding: .3rem; gap: .3rem; margin: 0 0 6px; }
  .dg-bar .dg-top { flex: none; flex-direction: column; align-items: stretch; gap: .25rem; }
  .dg-bar .dg-banner { font-size: .95rem; padding: .3rem; }
  .dg-bar .dg-banner .pattern, .dg-bar .dg-banner .secret { display: block; margin: 0; font-size: 1.3rem; white-space: normal; }
  .dg-bar .dg-timer { font-size: 1.5rem; }
  .dg-bar .dg-modes, .dg-bar .dg-play, .dg-bar .dg-drawer-btns { flex: none; flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .dg-bar .btn-kid { flex: none; font-size: .95rem; min-height: 46px; }
  .dg-bar .dg-guess { flex: none; max-width: none; }
  .dg-bar .dg-guess .btn-kid { flex: none; }
  .draw-grid.dg-guessing > .tool-panel.order-2 { display: none; }
}

/* ---- Draw & Guess (13 Nov 2026): type-only guessing, word levels, guessers get the board + the guess feed (no tools) ---- */
.draw-grid.dg-guessing > .tool-panel.order-2 { display: none !important; }
@media (min-width: 700px) {
  .draw-grid.dg-guessing { grid-template-columns: minmax(0, 1fr) minmax(200px, 270px) !important; }
  .draw-grid.dg-guessing > :last-child { grid-column: auto !important; }
}
.dg-guess { flex: 1 1 260px; max-width: 520px; }
.dg-guess .input-kid { font-size: 1.35rem; min-height: 52px; letter-spacing: .03em; }
.dg-levels { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; justify-content: center; width: 100%; font-weight: 800; color: #a61e4d; }
.dg-levels .on { box-shadow: 0 0 0 4px #f06595; }
.dg-feed { height: auto; min-height: 140px; max-height: 42vh; }
.dg-guess { flex-wrap: wrap; }
.dg-guess .input-kid { flex: 1 1 150px; }
.dg-guess .btn-kid { flex: 1 0 auto; }
/* letter tiles for the youngest guessers (age 4-5) */
.dg-tiles { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; flex: 1 1 100%; }
.dg-tiles button { min-width: 46px; min-height: 48px; font-size: 1.5rem; font-weight: 900; text-transform: uppercase; background: #fff; border: 3px solid #fcc2d7; border-radius: 12px; color: #a61e4d; }
.dg-tiles button:active { transform: scale(.92); }
.dg-tiles button.used { opacity: .35; }
.dg-tiles .del { background: #fff5f5; border-color: #ffc9c9; }
/* ✖ Exit: back to the map from every world, game, Home and the Wardrobe */
.world-exit { margin-left: auto; flex: none !important; border: 3px solid #ffc9c9 !important; color: #c92a2a !important; }
