:root {
  --ink: #2c2420;
  --paper: #fffaf0;
  --paper-2: #f6ecd8;
  --accent: #e5734b;
  --accent-dk: #c4552f;
  --green: #5bab4a;
  --sky: #3fa7c9;
  --gold: #e8b53c;
  --shadow: 0 6px 18px rgba(40, 25, 10, 0.25);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7cb85a; color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 20; padding: 24px; }
.screen.dim { background: rgba(30, 24, 18, 0.45); backdrop-filter: blur(3px); }
#menu { background: linear-gradient(180deg, rgba(255, 245, 220, 0) 0%, rgba(255, 240, 210, 0) 55%, rgba(60, 40, 20, 0.4) 100%); justify-content: flex-end; padding-bottom: 6vh; }
#menu .menu-buttons { align-items: center; max-width: 980px; }
#menu .menu-buttons .primary.big { min-width: 320px; }
#menu .row2 { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.title { text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(90, 50, 20, 0.35), 0 8px 24px rgba(40, 20, 0, 0.35); position: absolute; top: 9vh; left: 0; right: 0; pointer-events: none; }
.title h1 { font-size: clamp(64px, 13vw, 150px); margin: 0; letter-spacing: 0.02em; line-height: 0.95; color: #fff6e4; -webkit-text-stroke: 3px #8a5a34; paint-order: stroke fill; }
.title p { font-size: clamp(18px, 2.6vw, 28px); margin: 8px 0 0; font-weight: 700; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 260px; }
.menu-buttons.row { flex-direction: row; justify-content: flex-end; min-width: 0; flex-wrap: wrap; }
.primary, .ghost, .danger { border: 0; border-radius: 16px; padding: 12px 22px; font-size: 18px; font-weight: 800; text-decoration: none; text-align: center; transition: transform 0.08s, filter 0.15s; }
.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dk), var(--shadow); }
.primary.big { font-size: 24px; padding: 16px 28px; }
.ghost { background: rgba(255, 250, 240, 0.92); color: var(--ink); box-shadow: 0 3px 0 #d8c7a6, var(--shadow); }
.danger { background: #fbe4dc; color: #a2331c; box-shadow: 0 3px 0 #e2b6a6; }
.primary:hover, .ghost:hover, .danger:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary:active, .ghost:active, .danger:active { transform: translateY(2px); }
.stats { color: #fff; font-weight: 700; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); margin: 0; min-height: 1em; }
#loading { position: absolute; bottom: 3vh; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
#loading .track { width: 240px; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
#loading i { display: block; height: 100%; width: 0; background: #fff6e4; border-radius: 6px; transition: width 0.2s; }
body.loading #menu .menu-buttons { opacity: 0.5; pointer-events: none; }

.panel { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow), 0 0 0 4px rgba(255, 255, 255, 0.5); padding: 22px 24px; max-height: 90vh; overflow: auto; }
.panel.narrow { width: min(520px, 94vw); }
.panel.wide { width: min(860px, 96vw); display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0 0 8px; font-size: 28px; }
.panel header { display: flex; justify-content: space-between; align-items: center; }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; font-weight: 700; }
.panel label.check { justify-content: flex-start; }
.panel input[type=range] { width: 55%; accent-color: var(--accent); }
.panel select { font: inherit; padding: 4px 8px; border-radius: 8px; }
.hint { color: #7a6a5a; font-size: 14px; }
.help ul { padding-left: 20px; line-height: 1.5; }
.paws-big { font-size: 22px; font-weight: 800; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 0; background: var(--paper-2); padding: 8px 16px; border-radius: 12px; font-weight: 800; color: #6a5a4a; }
.tabs button.on { background: var(--accent); color: #fff; }

/* task book */
.task-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.task-list li { display: flex; align-items: center; gap: 10px; background: var(--paper-2); border-radius: 12px; padding: 8px 10px; }
.task-list li.done { background: #e2f2d4; }
.task-list .ico { font-size: 22px; width: 30px; text-align: center; }
.task-list .txt { flex: 1; font-weight: 700; font-size: 14px; line-height: 1.2; }
.task-list .txt small { display: block; font-weight: 600; color: #8a7a6a; }
.task-list .rw { font-weight: 800; color: #8a6a3a; white-space: nowrap; }
.task-list li.done .rw::before { content: '✓ '; color: var(--green); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.slot { background: var(--paper-2); border-radius: 14px; padding: 12px 8px; text-align: center; font-weight: 700; font-size: 13px; }
.slot .big { font-size: 40px; display: block; }
.slot.no { opacity: 0.55; }
.slot.no .big { filter: grayscale(1) brightness(0.3); }
.wardrobe { display: flex; flex-direction: column; gap: 12px; }
.wardrobe h3 { margin: 6px 0; }
.hats { display: flex; flex-wrap: wrap; gap: 8px; }
.hats button { border: 0; background: var(--paper-2); border-radius: 12px; padding: 8px 10px; font-weight: 700; min-width: 86px; }
.hats button .big { font-size: 26px; display: block; }
.hats button.on { background: var(--accent); color: #fff; }
.hats button:disabled { opacity: 0.45; cursor: default; }

/* customise */
#custom { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#custom .panel.side { pointer-events: auto; position: absolute; right: 16px; top: 16px; bottom: 16px; width: min(400px, 92vw); display: flex; flex-direction: column; gap: 10px; }
#custom-body { flex: 1; overflow: auto; }
.opt { margin: 10px 0 14px; }
.opt > b { display: block; margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.swatches button.on { outline: 3px solid var(--accent); }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { border: 0; background: var(--paper-2); border-radius: 10px; padding: 7px 12px; font-weight: 700; }
.choices button.on { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-tl { position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#who { display: flex; align-items: center; gap: 10px; background: rgba(255, 250, 240, 0.92); border-radius: 18px; padding: 6px 14px 6px 6px; box-shadow: var(--shadow); }
#who .face { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: #f3d9b4; }
#who b { display: block; font-size: 20px; line-height: 1; }
#who small { color: #7a6a5a; font-weight: 700; }
#paws { background: rgba(255, 250, 240, 0.92); border-radius: 14px; padding: 4px 12px; font-weight: 800; font-size: 18px; box-shadow: var(--shadow); display: flex; gap: 6px; }
#paws.bump { animation: bump 0.5s; }
@keyframes bump { 30% { transform: scale(1.3); } }
#status { display: flex; gap: 6px; }
#status span { background: rgba(255, 250, 240, 0.85); border-radius: 10px; padding: 2px 8px; font-size: 14px; font-weight: 700; }
.hud-tr { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#clock { background: rgba(255, 250, 240, 0.92); border-radius: 14px; padding: 4px 12px; box-shadow: var(--shadow); display: flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 18px; }
#clock small { color: #7a6a5a; font-size: 13px; }
#tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; max-width: 300px; }
#tasks li { background: rgba(255, 250, 240, 0.85); border-radius: 12px; padding: 4px 10px; font-size: 14px; font-weight: 700; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
#tasks li small { color: #8a6a3a; margin-left: 4px; }
#tasks li.new { animation: slide 0.4s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: 34px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#prompt { background: rgba(40, 30, 22, 0.78); color: #fff; padding: 8px 16px; border-radius: 16px; font-weight: 800; font-size: 18px; display: flex; gap: 10px; align-items: center; }
kbd { background: #fff6e4; color: var(--ink); border-radius: 7px; padding: 2px 8px; font: inherit; font-weight: 900; box-shadow: 0 2px 0 #c9b48e; }
#hint { background: rgba(229, 115, 75, 0.92); color: #fff; padding: 6px 14px; border-radius: 14px; font-weight: 800; font-size: 16px; }
#charge { width: 180px; height: 12px; background: rgba(0, 0, 0, 0.35); border-radius: 8px; overflow: hidden; }
#charge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f5d547, #e5534b); }
.keys { position: absolute; left: 14px; bottom: 14px; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); line-height: 1.6; opacity: 0.9; }
.keys kbd { font-size: 12px; padding: 0 6px; }
#toasts { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--paper); border-radius: 16px; padding: 10px 18px; font-weight: 800; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; animation: pop 0.35s cubic-bezier(.2, 1.6, .5, 1); }
.toast .big { font-size: 28px; }
.toast small { display: block; color: #8a6a3a; font-size: 13px; }
.toast.out { animation: fadeout 0.4s forwards; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes fadeout { to { transform: translateY(-10px); opacity: 0; } }
#btn-pause { pointer-events: auto; position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 250, 240, 0.9); box-shadow: var(--shadow); display: flex; gap: 5px; align-items: center; justify-content: center; }
#btn-pause i { width: 5px; height: 16px; background: var(--ink); border-radius: 2px; }

/* speech bubbles */
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.say { position: absolute; transform: translate(-50%, -100%); background: #fff; color: var(--ink); border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 15px; white-space: nowrap; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2); animation: pop 0.25s; }
.say::after { content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; }
.say b { color: var(--accent-dk); margin-right: 4px; }
.say.think { font-size: 22px; padding: 2px 10px; border-radius: 50%; }
.say.think::after { border: 0; width: 8px; height: 8px; background: #fff; border-radius: 50%; bottom: -12px; }
.tag { position: absolute; transform: translate(-50%, -100%); color: #fff; font-weight: 800; font-size: 13px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); white-space: nowrap; }

#flash { position: fixed; inset: 0; pointer-events: none; z-index: 6; background: radial-gradient(circle, rgba(255, 255, 255, 0.0) 30%, rgba(255, 240, 255, 0.85) 100%); opacity: 0; transition: opacity 0.25s; }
#flash.on { opacity: 1; transition: opacity 0.1s; }
#fade { position: fixed; inset: 0; pointer-events: none; z-index: 7; background: #0c1430; opacity: 0; transition: opacity 0.8s; display: grid; place-items: center; color: #fff; font-size: 34px; font-weight: 800; }
#fade.on { opacity: 1; }

/* touch */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.tbtns { position: absolute; right: 12px; bottom: 70px; display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; pointer-events: auto; direction: rtl; }
.tbtns button { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(255, 250, 240, 0.8); box-shadow: var(--shadow); font-size: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; direction: ltr; }
.tbtns button small { font-size: 10px; font-weight: 800; margin-top: 2px; }
.tbtns button.big { background: rgba(229, 115, 75, 0.9); color: #fff; }
.tbtns button.on { transform: scale(0.92); filter: brightness(0.9); }
body.touch .keys { display: none; }
body.compact .hud-tr #tasks { display: none; }

@media (max-width: 700px) {
  #tasks { max-width: 190px; }
  #tasks li { font-size: 12px; }
  #who b { font-size: 16px; }
  .title { top: 5vh; }
}
@media (max-height: 520px) {
  body.touch #tasks { display: none; }
  .tbtns { grid-template-columns: repeat(3, 54px); gap: 8px; bottom: 64px; }
  .tbtns button { width: 54px; height: 54px; font-size: 20px; }
  .hud-bottom { bottom: 14px; }
  #toasts { top: 70px; }
}

/* ------------------------------------------------------------ new games */
#wishes { background: rgba(255, 250, 240, 0.92); border-radius: 14px; padding: 6px 10px 8px; box-shadow: var(--shadow); max-width: 320px; }
#wishes h4 { margin: 0 0 4px; font-size: 13px; color: #a2331c; text-transform: uppercase; letter-spacing: 0.04em; }
#wishes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#wishes li { font-size: 13px; font-weight: 700; display: flex; gap: 6px; align-items: flex-start; line-height: 1.25; }
#wishes li .f { font-size: 16px; }
#wishes li small { color: #8a6a3a; margin-left: 2px; white-space: nowrap; }
#wishes li.done { opacity: 0.55; text-decoration: line-through; }
#banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(40, 30, 22, 0.82); color: #fff; border-radius: 16px; padding: 6px 18px; text-align: center; font-weight: 800; }
#banner b { font-size: 26px; display: block; font-variant-numeric: tabular-nums; }
#banner small { font-size: 13px; opacity: 0.9; }
#cmd { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); text-align: center; background: rgba(255, 250, 240, 0.95); border-radius: 20px; padding: 10px 26px 12px; box-shadow: var(--shadow); min-width: 240px; }
#cmd .who { font-size: 14px; font-weight: 800; color: #8a6a3a; }
#cmd b { display: block; font-size: 40px; line-height: 1.1; }
#cmd .track { height: 8px; background: #eadfca; border-radius: 6px; overflow: hidden; margin: 6px 0 4px; }
#cmd .track i { display: block; height: 100%; background: var(--green); }
#cmd small { font-weight: 800; color: #6a5a4a; }
#cmd.good { animation: pop 0.3s; background: #e2f2d4; }
#cmd.bad { animation: shake 0.3s; background: #fbe4dc; }
@keyframes shake { 25% { transform: translateX(calc(-50% - 8px)); } 75% { transform: translateX(calc(-50% + 8px)); } }
#pops { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop { font-weight: 900; font-size: 28px; color: #fff; -webkit-text-stroke: 1.5px #8a3a1a; paint-order: stroke fill; animation: rise 1.3s forwards; white-space: nowrap; }
.pop.big { font-size: 38px; color: #ffe14a; }
.pop.bad { color: #ff9a8a; }
@keyframes rise { 0% { transform: scale(0.5); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-40px); opacity: 0; } }
#count { position: fixed; inset: 0; background: rgba(10, 14, 30, 0.93); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 7; }
#count b { font-size: 140px; line-height: 1; }
#count small { font-size: 22px; font-weight: 800; }
.play-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 8px 0 12px; }
.play-list button { border: 0; background: var(--paper-2); border-radius: 16px; padding: 14px 10px; font-weight: 800; font-size: 17px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.play-list button .big { font-size: 34px; }
.play-list button small { font-weight: 700; color: #8a7a6a; font-size: 12px; }
.play-list button:hover { background: #f1dfc0; }
#trickbar { position: absolute; right: 12px; bottom: 300px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 230px; justify-content: flex-end; pointer-events: auto; }
#trickbar button { width: 52px; height: 52px; border-radius: 14px; border: 0; background: rgba(255, 250, 240, 0.9); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
#trickbar button small { font-size: 9px; font-weight: 800; }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.records div { background: var(--paper-2); border-radius: 14px; padding: 12px; text-align: center; font-weight: 800; }
.records .big { font-size: 34px; display: block; }
.records b { font-size: 22px; display: block; }
@media (max-height: 520px) {
  body.touch #wishes { display: none; }
  #cmd { top: 12%; }
  #count b { font-size: 90px; }
}
