:root {
  color-scheme: light;
  --ink: #254b5a;
  --blue: #66b9ca;
  --red: #f66c5f;
  --yellow: #f7c94d;
  --paper: #f8f1de;
  --paper-dark: #eadcbd;
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive;
}

* { box-sizing: border-box; }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: #92cfce;
  background-image:
    radial-gradient(circle at 15% 13%, rgba(255,255,255,.28) 0 2px, transparent 2.5px),
    radial-gradient(circle at 83% 75%, rgba(21,97,102,.1) 0 1.5px, transparent 2px),
    repeating-linear-gradient(125deg, rgba(255,255,255,.05) 0 1px, transparent 1px 7px);
}

button { font: inherit; cursor: pointer; }

.game-shell {
  min-height: 100vh;
  padding: clamp(14px, 3vw, 34px) 16px 17px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
}

.game-card {
  width: min(100%, 1100px);
  overflow: hidden;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 18px 22px 15px 20px;
  box-shadow: 6px 8px 0 rgba(29, 80, 89, .33), -2px 2px 0 rgba(255,255,255,.65) inset;
  transform: rotate(-.18deg);
}

.topbar, .footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9e9bd;
}

.topbar {
  min-height: 73px;
  padding: 8px clamp(14px, 3vw, 30px) 7px;
  border-bottom: 3px solid var(--ink);
}

.brand { display: flex; align-items: center; gap: 9px; line-height: .9; }
.brand-star { color: var(--yellow); font-size: 38px; transform: rotate(-12deg); text-shadow: 1px 2px var(--ink); }
.brand p { margin: 0 0 2px; color: #ef775e; font-family: 'Gaegu', cursive; font-weight: 700; font-size: 15px; letter-spacing: 1.5px; }
.brand h1 { margin: 0; font: 700 clamp(23px, 4vw, 34px)/.86 'Gaegu', cursive; letter-spacing: .5px; }
.top-actions { display: flex; align-items: center; gap: 9px; }

.icon-button, .restart-button {
  min-height: 37px;
  border: 2px solid var(--ink);
  border-radius: 10px 8px 10px 7px;
  color: var(--ink);
  background: #fff8e8;
  box-shadow: 2px 2px 0 var(--ink);
}
.icon-button { width: 39px; padding: 0; font-size: 21px; }
.restart-button { padding: 2px 10px; font-size: 18px; }
.icon-button:hover, .restart-button:hover { background: #fff; transform: translate(-1px, -1px); }
.icon-button:active, .restart-button:active, .primary-button:active { box-shadow: none; transform: translate(2px, 2px); }

.hud-row {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 8px clamp(14px, 3vw, 30px) 9px;
  border-bottom: 2px dashed rgba(37,75,90,.55);
  background: #fff8e8;
}
.level-label { white-space: nowrap; font-family: 'Gaegu', cursive; font-size: 18px; }
.level-label span { display: inline-block; margin-right: 7px; color: #f06d62; font-size: 14px; letter-spacing: 1px; }
.level-label strong { font-size: 20px; }
.progress-wrap { width: min(47vw, 420px); display: flex; align-items: center; gap: 8px; font-family: 'Gaegu', cursive; font-weight: 700; font-size: 17px; }
.progress-track { flex: 1; height: 15px; padding: 2px; overflow: hidden; border: 2px solid var(--ink); border-radius: 20px 17px 18px 16px; background: #e5f3e3; }
.progress-fill { height: 100%; width: 0; border-radius: 13px; background: repeating-linear-gradient(105deg, #f5ca52 0 8px, #ffc94e 8px 11px); transition: width .12s linear; }

.game-stage { position: relative; height: min(62vw, 590px); min-height: 440px; overflow: hidden; background: #a9dbe2; touch-action: manipulation; }
.game-stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: .52; background-image: repeating-linear-gradient(0deg, transparent 0 30px, rgba(82,151,173,.15) 30px 31px), repeating-linear-gradient(90deg, transparent 0 30px, rgba(82,151,173,.08) 30px 31px); }
canvas { display: block; width: 100%; height: 100%; }

.corner-note { position: absolute; z-index: 2; top: 21px; font: 700 clamp(14px, 2.2vw, 19px)/.94 'Gaegu', cursive; color: rgba(37,75,90,.75); transform: rotate(-4deg); pointer-events: none; }
.note-left { left: clamp(13px, 3.2vw, 30px); }
.note-right { right: clamp(13px, 3.2vw, 30px); text-align: right; transform: rotate(4deg); }

.screen-card { position: absolute; z-index: 4; top: 50%; left: 50%; width: min(88%, 430px); padding: 22px 23px 16px; text-align: center; border: 3px solid var(--ink); border-radius: 22px 18px 24px 17px; background: rgba(255,250,233,.96); box-shadow: 6px 7px 0 rgba(37,75,90,.52); transform: translate(-50%, -50%) rotate(-1deg); }
.screen-card::before, .screen-card::after { position: absolute; color: #ef8c6e; font-size: 26px; }
.screen-card::before { content: '✦'; left: 15px; top: 12px; transform: rotate(-16deg); }
.screen-card::after { content: '✦'; right: 15px; bottom: 11px; color: #6ebfc4; transform: rotate(17deg); }
.scribble-cloud { margin: -31px auto -12px; color: #fbf7e8; font-size: 55px; text-shadow: 2px 2px var(--ink), -1px -1px var(--ink); transform: rotate(-6deg); }
.eyebrow { margin: 0 0 3px; color: #e86f60; font: 700 17px 'Gaegu', cursive; letter-spacing: 1.2px; }
.screen-card h2 { margin: 0; font: 700 clamp(37px, 8vw, 55px)/.88 'Gaegu', cursive; color: var(--ink); letter-spacing: 1px; }
.intro { max-width: 305px; margin: 9px auto 11px; font-size: 20px; line-height: .95; }
.primary-button { position: relative; z-index: 1; padding: 7px 19px 8px; border: 3px solid var(--ink); border-radius: 12px 10px 11px 9px; background: var(--red); color: white; box-shadow: 3px 4px 0 var(--ink); font: 700 24px/1 'Gaegu', cursive; letter-spacing: .5px; }
.primary-button span { display: inline-block; margin-right: 5px; font-size: 18px; transform: rotate(-3deg); }
.hint { margin: 9px 0 0; color: rgba(37,75,90,.75); font-size: 16px; }
.hidden { display: none; }

.name-field { display: grid; gap: 3px; max-width: 242px; margin: 0 auto 4px; text-align: left; }
.name-field span { padding-left: 5px; color: #e86f60; font: 700 15px/1 'Gaegu', cursive; letter-spacing: 1px; }
.name-field input { width: 100%; height: 35px; padding: 3px 11px; border: 2px solid var(--ink); border-radius: 9px 11px 8px 10px; outline: none; background: #fffef4; color: var(--ink); font: 20px 'Patrick Hand', cursive; box-shadow: 1px 2px 0 rgba(37,75,90,.25) inset; }
.name-field input:focus { border-color: #ef775e; box-shadow: 0 0 0 3px rgba(246,108,95,.18); }
.name-error { min-height: 14px; margin: 0 auto 4px; color: #d95450; font-size: 14px; line-height: 1; }
.level-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; max-width: 326px; margin: 0 auto 9px; }
.level-choice { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 3px 2px; border: 2px solid var(--ink); border-radius: 10px 8px 11px 7px; background: #fff9e8; color: var(--ink); box-shadow: 1px 2px 0 rgba(37,75,90,.36); font: 700 13px/.9 'Gaegu', cursive; text-align: left; }
.level-choice b { color: #e66f5c; font-size: 22px; line-height: 1; }.level-choice span { letter-spacing: .35px; }.level-choice:hover { background: #fff; transform: translate(-1px, -1px); }.level-choice.selected { background: #f8d869; box-shadow: 2px 3px 0 var(--ink); transform: translate(-1px, -1px) rotate(-1deg); }.level-choice:nth-child(2).selected { background: #cfc4ee; }.level-choice:nth-child(3).selected { background: #8fd0c8; }
.leaderboard { margin: 11px auto 0; max-width: 320px; overflow: hidden; border: 2px solid var(--ink); border-radius: 11px 9px 12px 8px; background: #ecf3d5; transform: rotate(.4deg); }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 3px 8px 2px; border-bottom: 1px dashed rgba(37,75,90,.62); background: #d2e7ad; }
.leaderboard h3 { margin: 0; white-space: nowrap; font: 700 17px/1 'Gaegu', cursive; letter-spacing: .6px; }.leaderboard-heading span { color: #56898a; font: 700 11px 'Gaegu', cursive; letter-spacing: .7px; }
.leaderboard-rows { min-height: 68px; margin: 0; padding: 2px 7px 3px 29px; text-align: left; }
.leaderboard-rows li { min-height: 19px; padding-left: 1px; color: #254b5a; font: 17px/1.05 'Gaegu', cursive; }
.leaderboard-rows li::marker { color: #e7795f; font-weight: 700; }.leaderboard-rows li.empty-score { padding-top: 16px; color: #628488; font-size: 15px; list-style: none; text-align: center; }
.score-name { display: inline-block; max-width: 165px; overflow: hidden; vertical-align: bottom; text-overflow: ellipsis; white-space: nowrap; }.score-number { float: right; color: #e86f60; font-weight: 700; }.score-stars { margin-left: 5px; color: #a98926; font-size: 14px; }
.score-receipt { max-width: 280px; margin: 0 auto 12px; padding: 6px 8px; border: 2px dashed #e57962; border-radius: 9px; background: #fff0c8; color: #315e66; font: 17px/1.02 'Gaegu', cursive; }

.footer-bar { min-height: 46px; padding: 5px clamp(14px, 3vw, 30px); border-top: 2px solid var(--ink); font-family: 'Gaegu', cursive; font-size: 18px; }
.star-count { color: #ed755e; font-size: 20px; }.star-count span { color: var(--yellow); text-shadow: 1px 1px var(--ink); }.star-count b { color: var(--ink); }.star-count small { color: rgba(37,75,90,.75); font: 16px 'Patrick Hand', cursive; }
.footer-tip { color: #4d8f99; font-size: 17px; letter-spacing: .4px; }.footer-tip span { color: #ef665c; }.attempt-count { color: rgba(37,75,90,.74); }.attempt-count b { color: var(--ink); }
.made-note { margin: 0; color: #f1f9ea; font-size: 18px; text-shadow: 1px 1px rgba(21, 94, 96, .45); }

@media (max-width: 610px) {
  .game-shell { padding-inline: 7px; }
  .game-card { border-width: 3px; }
  .topbar { min-height: 60px; }.brand-star { font-size: 29px; }.brand p { font-size: 12px; }.restart-button span { display: none; }.restart-button { width: 37px; padding: 1px; font-size: 22px; }
  .hud-row { gap: 7px; }.level-label strong { font-size: 17px; }.level-label span { display: none; }.progress-wrap { width: 39vw; font-size: 15px; }
  .game-stage { height: 134vw; min-height: 500px; }.corner-note { top: 12px; font-size: 14px; }.note-right { max-width: 91px; }
  .screen-card { padding: 20px 17px 14px; }.screen-card h2 { font-size: 44px; }.start-screen .intro { margin-bottom: 8px; font-size: 19px; }.level-picker { max-width: 305px; margin-bottom: 7px; }.level-choice { min-height: 44px; font-size: 12px; }.level-choice b { font-size: 20px; }.leaderboard { margin-top: 9px; }.leaderboard-rows { min-height: 63px; }.leaderboard-rows li { font-size: 16px; }
  .footer-tip { display: none; }.footer-bar { min-height: 40px; }
}
