:root {
  --ink: #12365e;
  --green: #057141;
  --yellow: #ffc928;
  --red: #f3573f;
  --blue: #208ac1;
  --paper: #fffdf1;
  --muted: #64748b;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: #f9f1c8;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 15% 8%, #cae5b6 0, transparent 27%), radial-gradient(circle at 85% 4%, #fbd45c 0, transparent 32%), #f8edb8; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.paper { background: rgba(255, 253, 239, .95); box-shadow: 0 16px 50px rgba(28, 70, 53, .16); }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-screen::before { content: ""; position: absolute; inset: 0; opacity: .48; background: radial-gradient(circle at 8% 18%, #74b77b 0 4%, transparent 16%), radial-gradient(circle at 88% 12%, #ffd33f 0 6%, transparent 20%), radial-gradient(circle at 70% 88%, #f49d75 0 3%, transparent 17%); filter: blur(10px); }
.login-card { position: relative; width: min(470px, 100%); border: 2px solid rgba(255,255,255,.8); border-radius: 36px; padding: 42px; text-align: center; }
.login-card h1, .hero h1 { color: var(--green); font-size: clamp(2.8rem, 8vw, 5.7rem); line-height: .9; margin: 8px 0 18px; font-weight: 900; letter-spacing: .02em; transform: rotate(-1deg); }
.login-card p:not(.eyebrow) { font-size: 1.05rem; }
.login-leaves { font-size: 3rem; }
.eyebrow { color: #ca4d2d; text-transform: uppercase; font-size: .78rem; font-weight: 900; letter-spacing: .16em; }
form { display: grid; gap: 10px; text-align: left; margin: 28px 0 18px; }
.telegram-login { display: grid; min-height: 58px; place-items: center; gap: 12px; margin: 28px 0 14px; }
.telegram-login-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; border: 0; border-radius: 999px; padding: 13px 24px; color: #fff; background: #229ed9; box-shadow: 0 6px 0 #147aa9; font-weight: 900; text-decoration: none; }
.telegram-login-button span { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: #229ed9; background: #fff; transform: rotate(-20deg); }
.telegram-login-button:active { transform: translateY(3px); box-shadow: 0 3px 0 #147aa9; }
.telegram-login-button:disabled { cursor: wait; opacity: .6; }
.telegram-login-status { display: grid; gap: 5px; max-width: 340px; padding: 14px 18px; border-radius: 18px; color: #18516a; background: #e6f6fd; }
.telegram-login-status span { color: #456c7c; font-size: .88rem; line-height: 1.35; }
.telegram-login-link { border: 0; padding: 4px; color: #087ead; background: none; text-decoration: underline; font-size: .88rem; font-weight: 900; }
.login-loader { color: var(--muted); font-size: .9rem; font-weight: 800; }
.login-error { min-height: 1.3em; margin-bottom: 12px; text-align: center; }
label { font-weight: 800; }
input, textarea { width: 100%; border: 2px solid #d7dfce; border-radius: 15px; padding: 13px 15px; color: var(--ink); background: white; outline: none; }
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(5,113,65,.12); }
.primary { border: 0; border-radius: 999px; color: #fff; background: var(--green); padding: 13px 22px; font-weight: 900; box-shadow: 0 7px 0 #045b35; }
.primary:active { transform: translateY(3px); box-shadow: 0 4px 0 #045b35; }
.primary:disabled { cursor: not-allowed; opacity: .48; filter: grayscale(.4); }
.wide { width: 100%; margin-top: 8px; }
.telegram-mark { background: #fff; color: var(--green); width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; margin-right: 6px; }
small { color: var(--muted); }

.game { width: min(1180px, 100%); margin: auto; padding: 0 20px 44px; }
.hero { min-height: 270px; display: grid; grid-template-columns: 1fr 2.5fr 1fr; align-items: center; padding: 28px 10px 18px; }
.hero-title { text-align: center; }
.hero-title p { display: inline-block; font-family: "Caveat", cursive; font-size: clamp(1.7rem, 4vw, 2.7rem); color: var(--ink); margin: 0 0 18px; padding: 3px 26px 7px; background: rgba(255,255,255,.68); border-bottom: 5px solid #ef6845; transform: rotate(-1deg); }
.hero-art { font-size: clamp(2rem, 5vw, 4.2rem); text-align: center; transform: rotate(-8deg); }
.hero-art.right { transform: rotate(8deg); }
.topline { display: flex; justify-content: center; gap: 16px; font-size: .85rem; font-weight: 800; }
.text-button { border: 0; background: none; color: #b5472f; text-decoration: underline; padding: 0; }
.hero-progress { max-width: 460px; margin: auto; font-weight: 900; }
.progress-track { height: 10px; margin-top: 7px; background: rgba(255,255,255,.8); border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.14); }
.progress-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg,#0b8b50,#81b942); transition: width .35s ease; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 4px 3px 18px; }
.intro p { margin: 0; font-weight: 800; }
.intro span { color: #61756d; font-size: .82rem; }

.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.task-card { --accent: var(--yellow); position: relative; display: flex; flex-direction: column; border: 3px solid rgba(255,255,255,.82); border-radius: 22px; overflow: hidden; min-width: 0; padding: 0; text-align: left; color: var(--ink); background: linear-gradient(155deg, rgba(255,255,255,.96), rgba(255,252,223,.94)); box-shadow: 0 6px 12px rgba(43,90,62,.15); transition: transform .18s ease, box-shadow .18s ease; isolation: isolate; }
.task-card:nth-child(4n+2), .task-card:nth-child(4n+3) { background: linear-gradient(155deg, rgba(250,255,240,.94), rgba(235,247,211,.9)); }
.task-card:nth-child(4n) { background: linear-gradient(155deg, rgba(255,248,237,.94), rgba(255,224,206,.82)); }
.task-card-head { position: relative; z-index: 3; display: flex; align-items: flex-start; gap: 11px; min-height: 120px; padding: 14px 13px 12px; }
.task-number { display: grid; flex: 0 0 auto; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: white; font-size: 1.8rem; line-height: 1; font-weight: 900; font-style: italic; box-shadow: inset 0 -3px 0 rgba(0,0,0,.1); }
.task-title { display: block; min-width: 0; padding-top: 2px; font-size: .96rem; line-height: 1.15; font-weight: 900; }
.task-visual { position: relative; display: block; width: 100%; aspect-ratio: 1; margin-top: auto; overflow: hidden; border-top: 2px solid rgba(12,78,59,.08); background: #fffbea; }
.task-visual img { display: block; width: 100%; height: 100%; object-fit: contain; transition: filter .25s ease, opacity .25s ease, transform .25s ease; }
.task-card.completed { border-color: #5aa454; box-shadow: 0 8px 22px rgba(0,111,65,.28); }
.task-card.completed .task-visual img { filter: saturate(.72); opacity: .64; }
.task-card.pending { border-color: #d79b14; box-shadow: 0 8px 22px rgba(215,155,20,.22); }
.task-card.pending .task-visual img { filter: saturate(.65); opacity: .72; }
.task-card.rejected { border-color: #d94c42; }
.checkmark { position: absolute; z-index: 5; right: 14px; bottom: 13px; display: grid; place-items: center; width: 47px; height: 47px; border-radius: 50%; border: 4px solid var(--ink); background: #fff; font-size: 0; }
.completed .checkmark { color: white; border-color: #067341; background: #0b8b50; font-size: 1.8rem; }
.pending .checkmark { color: #fff; border-color: #c58a0c; background: #e4a91e; font-size: 1.6rem; }
.auto-badge { position: absolute; z-index: 4; left: 14px; bottom: 16px; padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.9); color: #6b7280; font-size: .68rem; font-weight: 900; }
.status-badge { position: absolute; z-index: 4; left: 14px; bottom: 16px; padding: 5px 9px; border-radius: 99px; color: #fff; font-size: .68rem; font-weight: 900; text-transform: uppercase; }
.pending-badge { background: #b97800; }
.rejected-badge { background: #bd322b; }

@media (hover: hover) {
  .task-card:hover { transform: translateY(-4px) rotate(-.35deg); box-shadow: 0 13px 22px rgba(43,90,62,.2); }
  .task-card:nth-child(even):hover { transform: translateY(-4px) rotate(.35deg); }
  .task-card:hover .task-visual img { transform: scale(1.02); }
}

.total-progress { margin-top: 25px; border-radius: 24px; padding: 20px 24px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; border: 2px solid white; }
.total-copy { display: grid; }
.total-copy span { font-size: .8rem; color: var(--muted); font-weight: 800; }
.total-copy strong { font-size: 1.5rem; }
.progress-track.large { margin: 0; height: 15px; background: #e4eadc; }
#total-percent { font-size: 1.35rem; color: var(--green); min-width: 52px; text-align: right; }

dialog { color: var(--ink); border: 0; border-radius: 28px; padding: 0; box-shadow: 0 30px 90px rgba(0,35,27,.42); }
dialog::backdrop { background: rgba(5,38,34,.62); backdrop-filter: blur(4px); }
.task-dialog { width: min(720px, calc(100% - 24px)); max-height: min(900px, calc(100vh - 24px)); background: #edf4d6; overflow: auto; }
.dialog-close { position: sticky; z-index: 8; float: right; right: 15px; top: 15px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #eef1e8; color: var(--ink); font-size: 1.6rem; line-height: 1; }
.dialog-inner { padding: 31px 34px 34px; }
.expanded-card { overflow: hidden; border: 2px solid rgba(255,255,255,.92); border-radius: 28px; background: var(--paper); box-shadow: 0 12px 34px rgba(28,70,53,.13); }
.expanded-card .dialog-heading { padding: 24px 64px 20px 24px; }
.dialog-heading { display: flex; gap: 15px; align-items: start; padding-right: 32px; }
.dialog-heading .task-number { position: static; flex: 0 0 auto; }
.dialog-heading h2 { margin: 2px 0 8px; font-size: clamp(1.25rem, 4vw, 1.75rem); line-height: 1.15; }
.expanded-visual { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-block: 2px solid rgba(12,78,59,.08); background: #fffbea; }
.expanded-visual img { display: block; width: 100%; height: 100%; object-fit: contain; }
.expanded-check { position: absolute; right: 22px; bottom: 22px; display: grid; width: 64px; height: 64px; place-items: center; border: 5px solid var(--ink); border-radius: 50%; color: transparent; background: rgba(255,255,255,.92); font-size: 2rem; font-weight: 900; }
.expanded-check.accepted { border-color: #067341; color: #fff; background: #0b8b50; }
.expanded-check.pending { border-color: #c58a0c; color: #fff; background: #e4a91e; }
.expanded-check.rejected { border-color: #bd322b; color: #bd322b; background: #fff; }
.expanded-content { padding: 24px; }
.task-detail { margin: 0 0 22px; border-left: 4px solid #7aaa5a; border-radius: 0 14px 14px 0; padding: 13px 15px; color: #405f58; background: #f0f7df; line-height: 1.45; }
.field { margin: 17px 0; }
.field label { display: block; margin-bottom: 7px; }
.field-label { display: block; margin-bottom: 7px; font-weight: 800; }
.field-note { color: #6b7280; font-size: .78rem; margin-top: 6px; }
.numbered-events { overflow: hidden; border: 2px solid #0b7548; border-radius: 18px; background: #fff; box-shadow: 0 0 0 6px rgba(11,117,72,.1); }
.field .event-row { display: flex; align-items: center; gap: 9px; min-height: 62px; margin: 0; padding: 0 16px; border-bottom: 1px solid #e2e8df; }
.field .event-row:last-child { border-bottom: 0; }
.event-row > span { flex: 0 0 26px; color: #5d6670; font-size: 1.15rem; font-weight: 900; text-align: right; }
.event-row input { height: 60px; padding: 12px 4px; border: 0; border-radius: 0; background: transparent; }
.event-row input:focus { border: 0; box-shadow: none; }
.event-row:focus-within { background: #fbfff8; box-shadow: inset 4px 0 0 var(--green); }
.bonus { border-radius: 16px; padding: 13px 15px; background: #fff1b8; color: #7d5511; font-weight: 800; }
.upload { position: relative; min-height: 98px; border: 2px dashed #9eb69e; border-radius: 17px; background: #fff; display: grid; place-items: center; text-align: center; padding: 14px; overflow: hidden; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload.has-file { border-style: solid; border-color: var(--green); background: #edf9ed; }
.upload span { font-weight: 800; }
.upload small { display: block; margin-top: 4px; }
.walk-theme { margin: 20px 0 24px; padding: 22px 24px; border-radius: 20px; background: #fff0ad; color: #405f58; }
.walk-theme-label { display: block; margin-bottom: 6px; color: #805711; font-weight: 900; }
.walk-theme > strong { display: block; color: var(--ink); font-size: 1.65rem; line-height: 1.1; }
.walk-theme p { margin: 13px 0; line-height: 1.45; }
.walk-theme div { padding-top: 12px; border-top: 1px solid rgba(128,87,17,.2); line-height: 1.4; }
.external { display: inline-block; border: 2px solid #1688bd; color: #096d9b; text-decoration: none; border-radius: 999px; padding: 10px 16px; font-weight: 900; margin: 4px 0 12px; }
.confirm-row { display: flex; align-items: center; gap: 14px; margin-top: 24px; }
.confirm-row .primary { flex: 1; }
.completed-note { color: var(--green); font-weight: 900; text-align: center; }
.review-note { margin: 20px 0 4px; border-radius: 16px; padding: 14px 16px; font-weight: 800; line-height: 1.4; }
.pending-note { color: #7a5200; background: #fff1b8; }
.rejected-note { color: #922d27; background: #ffe1dc; }
.error { color: #b42318; font-size: .82rem; font-weight: 800; min-height: 1.2em; }
.bingo-dialog { width: min(470px, calc(100% - 32px)); padding: 46px 38px; text-align: center; background: linear-gradient(150deg,#fffced,#fff4b8); }
.bingo-dialog h2 { color: var(--green); font-size: 4rem; margin: 2px 0 12px; }
.confetti { font-size: 2.2rem; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translate(-50%, 30px); padding: 12px 18px; border-radius: 99px; color: white; background: #173c33; opacity: 0; pointer-events: none; transition: .25s ease; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .hero { grid-template-columns: .5fr 3fr .5fr; }
}

@media (max-width: 560px) {
  body { background: radial-gradient(circle at 12% 3%, #d9eabb 0, transparent 20%), radial-gradient(circle at 88% 1%, #fbd45c 0, transparent 22%), #f8edb8; }
  .game { padding: 0 12px calc(32px + env(safe-area-inset-bottom)); }
  .hero { min-height: 220px; grid-template-columns: 1fr; padding: 24px 4px 15px; }
  .hero-art { display: none; }
  .hero-title h1 { font-size: clamp(2.8rem, 16vw, 4.4rem); }
  .hero-title p { font-size: 1.65rem; padding-inline: 16px; }
  .topline { justify-content: space-between; padding: 0 5px; }
  .intro { display: block; margin: 6px 3px 14px; }
  .intro span { display: none; }
  .board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .task-card { width: 100%; border-width: 1.5px; border-radius: 11px; box-shadow: 0 3px 7px rgba(43,90,62,.15); }
  .task-card-head { min-height: 56px; gap: 4px; padding: 5px 4px 4px; }
  .task-number { width: 24px; height: 24px; font-size: .78rem; box-shadow: inset 0 -2px 0 rgba(0,0,0,.1); }
  .task-title { padding-top: 1px; font-size: clamp(.45rem, 1.8vw, .58rem); line-height: 1.06; letter-spacing: -.02em; }
  .task-visual { border-top-width: 1px; }
  .checkmark { width: 19px; height: 19px; right: 4px; bottom: 4px; border-width: 2px; }
  .completed .checkmark, .pending .checkmark { font-size: .72rem; }
  .status-badge, .auto-badge { left: 3px; bottom: 4px; max-width: calc(100% - 28px); padding: 2px 3px; font-size: .34rem; }
  .total-progress { position: sticky; z-index: 10; bottom: 8px; grid-template-columns: 1fr auto; gap: 10px; margin-top: 18px; padding: 16px 18px; backdrop-filter: blur(12px); }
  .total-progress .progress-track { grid-column: 1/-1; grid-row: 2; }
  .login-screen { padding: 14px; }
  .login-card { padding: 30px 20px; border-radius: 28px; }

  .task-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; overscroll-behavior: contain; }
  .task-dialog[open] { display: block; }
  .task-dialog #dialog-content { min-height: 100%; }
  .dialog-close { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; width: 50px; height: 50px; background: #edf0e8; font-size: 2rem; }
  .dialog-inner { min-height: 100dvh; padding: max(14px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)); }
  .expanded-card { min-height: calc(100dvh - max(26px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); border-radius: 24px; }
  .dialog-heading { gap: 14px; padding: 22px 66px 18px 18px; }
  .dialog-heading .task-number { width: 62px; height: 62px; font-size: 2rem; }
  .dialog-heading h2 { margin-top: 4px; font-size: clamp(1.35rem, 6vw, 1.7rem); line-height: 1.13; }
  .task-detail { margin: 18px 0; }
  .expanded-content { padding: 22px 18px 10px; }
  .field { margin: 19px 0; }
  .field .event-row { min-height: 64px; padding-inline: 12px; }
  .event-row input { height: 62px; font-size: 16px; }
  input, textarea { font-size: 16px; }
  .upload { min-height: 112px; }
  .walk-theme { margin: 22px 0; padding: 20px 18px; }
  .walk-theme > strong { font-size: 1.55rem; }
  .error { margin-top: auto; padding-top: 18px; }
  .confirm-row { position: sticky; z-index: 7; bottom: 0; margin-top: 0; padding: 14px 0 max(10px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255,253,241,0), var(--paper) 22%); }
  .confirm-row .primary { min-height: 58px; font-size: 1.05rem; }
  .bingo-dialog { width: calc(100% - 24px); padding: 38px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
