@font-face {
  font-family: 'Patrick Hand';
  src: url('fonts/PatrickHand.woff2') format('woff2');
  font-display: swap;
}
:root {
  --ink: #2b2b2b; --paper: #fffaf0; --blue: #2a7de1; --red: #e2574c; --green: #7bc142; --yellow: #ffd23f; --purple: #7b4dd6;
  --wob: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wob2: 15px 225px 15px 255px / 255px 15px 225px 15px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #e9dfc9; overflow: hidden;
  font-family: 'Patrick Hand', 'Comic Sans MS', 'Chalkboard SE', cursive; color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: manipulation;
}
body {
  background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex; align-items: center; justify-content: center;
}
#stage { position: relative; width: 960px; height: 540px; box-shadow: 0 6px 30px rgba(0,0,0,0.25); border-radius: 6px; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; background: #fdf3e1; }
#ui { position: absolute; left: 0; top: 0; width: 960px; height: 540px; transform-origin: 0 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }

.card {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--wob);
  box-shadow: 5px 6px 0 rgba(43,43,43,0.85); padding: 14px 22px;
  width: 520px; max-height: 512px; overflow: auto;
  background-image: repeating-linear-gradient(transparent 0 25px, rgba(70,110,200,0.12) 25px 26px);
}
.card.wide { width: 900px; }
.card.tall { height: 512px; display: flex; flex-direction: column; }
.card.small-card { width: 300px; top: 60px; text-align: center; }
.menu-card { width: 470px; text-align: center; padding-top: 6px; top: 10px; background-color: rgba(255,250,240,0.97); }

h1.logo { margin: 2px 0 0; font-size: 64px; line-height: 1; letter-spacing: 2px; font-weight: normal; }
h1.logo span { display: inline-block; text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); }
h1.logo span:nth-child(1) { color: #f39c34; transform: rotate(-8deg); }
h1.logo span:nth-child(2) { color: var(--yellow); transform: rotate(5deg) translateY(-3px); }
h1.logo span:nth-child(3) { color: var(--red); transform: rotate(-4deg); }
h1.logo span:nth-child(4) { color: var(--blue); transform: rotate(7deg) translateY(2px); }
h1.logo span:nth-child(5) { color: var(--green); transform: rotate(-6deg); }
h1.logo span:nth-child(6) { color: var(--purple); transform: rotate(4deg) translateY(-2px); }
h1.logo span:nth-child(7) { color: #f39c34; transform: rotate(-5deg); }
h1.logo span:nth-child(8) { color: var(--yellow); transform: rotate(6deg) translateY(3px); }
h1.logo span:nth-child(9) { color: var(--red); transform: rotate(-3deg); }
h1.logo:hover span { animation: wig 0.4s ease-in-out infinite alternate; }
@keyframes wig { to { translate: 0 -3px; } }
.tagline { margin: 4px 0 10px; font-size: 19px; line-height: 1.2; }
h2 { margin: 0; font-weight: normal; font-size: 32px; }

.btn {
  font: inherit; font-size: 22px; color: var(--ink); cursor: pointer;
  background: #fff; border: 2.5px solid var(--ink); border-radius: var(--wob2);
  padding: 4px 18px; box-shadow: 3px 3px 0 var(--ink); transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { transform: translate(-1px, -1px) rotate(-1deg); box-shadow: 4px 4px 0 var(--ink); background: #fff7d6; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible, .tab:focus-visible, .link:focus-visible, .map:focus-visible { outline: 3px dashed var(--blue); outline-offset: 3px; }
.btn.primary { background: var(--yellow); }
.btn.primary:hover { background: #ffe27a; }
.btn.big { font-size: 30px; padding: 4px 40px; }
.btn.small { font-size: 18px; padding: 2px 12px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.menu-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0 20px; }
.menu-buttons .big { grid-column: 1 / -1; justify-self: center; }
.menu-buttons.solo [data-act=help] { grid-column: 1 / -1; justify-self: center; }
.who { margin: 10px 0 2px; font-size: 18px; color: #555; min-height: 22px; }
.menu-foot { display: flex; flex-wrap: wrap; gap: 2px 16px; justify-content: center; }
.link { font: inherit; font-size: 18px; background: none; border: none; color: var(--blue); cursor: pointer; text-decoration: underline wavy rgba(42,125,225,0.4); padding: 2px; }

.bar { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.bar h2 { flex: 1; }
.bar .sum { font-size: 20px; color: #555; }

.map-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.map {
  position: relative; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  border: 2.5px solid var(--ink); border-radius: var(--wob); padding: 6px 10px 6px 12px; min-height: 92px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform 0.1s;
}
.map:nth-child(odd) { transform: rotate(-0.8deg); }
.map:nth-child(even) { transform: rotate(0.7deg); }
.map:hover:not(.locked) { transform: rotate(0deg) scale(1.04); z-index: 1; }
.map.c0 { background-color: #ffe3b3; }
.map.c1 { background-color: #e6dcff; }
.map.c2 { background-color: #d8f5c9; }
.map.c3 { background-color: #efe6d3; }
.map.c4 { background-color: #cdd6f6; }
.map.c5 { background-color: #d3f1f4; }
.map.c6 { background-color: #f3e2c4; }
.map.c7 { background-color: #ffd9c2; }
.map.c8 { background-color: #dde9d3; }
.map.c9 { background-color: #ffeccc; }
.map.c10 { background-color: #fff3b0; }
.map.c11 { background-color: #f8d6e7; }
.map.c12 { background-color: #ffeccc; }
.map.c13 { background-color: #ffd9c2; }
.map.c14 { background-color: #fbf1c6; }
.map.c15 { background-color: #fff3b0; }
.map.c16 { background-color: #f1ece4; }
.map.c17 { background-color: #ecd9c3; }
.map.c18 { background-color: #d6f3ff; }
.map.c19 { background-color: #f8d6e7; }
.world { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 22px; font-weight: normal; border-bottom: 2px dashed rgba(0,0,0,0.25); }
.map .num { font-size: 30px; line-height: 1; }
.map .name { font-size: 22px; line-height: 1.05; }
.map .meta { font-size: 16px; color: #333; margin-top: 2px; }
.map .badge { position: absolute; right: 8px; top: 4px; font-size: 22px; }
.map.locked { filter: grayscale(0.9); opacity: 0.55; cursor: not-allowed; }
.note { font-size: 17px; color: #555; margin: 10px 0 0; line-height: 1.25; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#board-tabs { display: grid; grid-template-columns: repeat(11, auto); }
.board tr.head td, .board tr.head td.s, .board tr.head td.m { font-size: 15px; opacity: 0.65; border-bottom: 2px dashed rgba(0,0,0,0.2); }
.tab {
  font: inherit; font-size: 18px; cursor: pointer; background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: var(--wob2); padding: 1px 10px;
}
.tab.active { background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); }
.board-wrap { flex: 1; overflow: auto; border-top: 2px dashed rgba(0,0,0,0.25); }
table.board { width: 100%; border-collapse: collapse; font-size: 21px; }
table.board td { padding: 3px 8px; border-bottom: 1px solid rgba(0,0,0,0.1); }
table.board td.r { text-align: right; width: 60px; color: #666; }
table.board td.s { text-align: right; font-size: 23px; }
table.board td.m { text-align: right; color: #666; font-size: 18px; width: 110px; }
table.board td.w { width: 40px; text-align: right; }
table.board td.w .tab { padding: 0 8px; font-size: 15px; }
table.board tr.me { background: rgba(255,210,63,0.45); }
table.board tr:nth-child(1) td.r::before { content: '🥇 '; }
table.board tr:nth-child(2) td.r::before { content: '🥈 '; }
table.board tr:nth-child(3) td.r::before { content: '🥉 '; }

form { display: flex; flex-direction: column; gap: 3px; }
label { display: flex; flex-direction: column; font-size: 19px; }
input {
  font: inherit; font-size: 22px; padding: 4px 10px; border: 2.5px solid var(--ink); border-radius: var(--wob2);
  background: #fff; outline: none; -webkit-user-select: text; user-select: text;
}
input:focus { background: #fffbe6; box-shadow: 3px 3px 0 var(--blue); }
.shop { flex: 1; display: flex; gap: 16px; min-height: 0; }
.shop-side { width: 280px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.shop-side canvas { width: 260px; height: 220px; }
.shop-name { font-size: 24px; margin: 2px 0 6px; }
.shop-side .note { font-size: 15px; margin-top: auto; }
.shop-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; align-content: start; padding: 4px; }
.sw { position: relative; height: 62px; border: 2px solid var(--ink); border-radius: 12px 10px 13px 9px; background: #fffaf0; cursor: pointer; font: inherit; font-size: 15px; padding: 2px; }
.sw i { display: block; width: 30px; height: 30px; margin: 2px auto 1px; border-radius: 50%; border: 2px solid var(--ink); }
.sw.sel { box-shadow: 0 0 0 3px var(--blue); }
.sw.on { background: var(--yellow); }
.sw.own:not(.on) { background: #e9f7e4; }
.err { color: var(--red); min-height: 22px; margin: 0; font-size: 19px; }
.hello { font-size: 28px; margin: 4px 0; }

ul.help { margin: 0; padding-left: 4px; list-style: none; font-size: 20px; line-height: 1.3; }
ul.help li { margin-bottom: 8px; }
kbd { display: inline-block; border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; background: #fff; font: inherit; font-size: 17px; box-shadow: 1px 2px 0 var(--ink); }

#scr-results { width: 560px; text-align: center; }
.card.over-card { width: 400px; top: 20px; overflow: hidden; }
.over-title { font-size: 44px; color: var(--red); transform: rotate(-2deg); }
.over-cause { font-size: 26px; margin: 0 0 4px; }
.over-card .lines { width: 320px; }
.result-title { font-size: 40px; color: #2a9d4b; }
.lines { margin: 6px auto; width: 380px; font-size: 22px; }
.lines div { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(0,0,0,0.2); }
.lines .tot { font-size: 34px; border: none; margin-top: 4px; }
.perfect { font-size: 20px; margin: 4px 0; color: #7b4dd6; }
.hint { font-size: 16px; color: #777; min-height: 18px; }
.hint.bad { color: var(--red); }
.hint.ok { color: #2a9d4b; }
.flag { font-size: 26px; color: var(--red); transform: rotate(-3deg); margin: 4px 0; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.col { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; align-items: center; }
.col .btn { width: 200px; }

.icon-btn {
  position: absolute; right: 10px; top: 10px; width: 46px; height: 46px; font-size: 22px; cursor: pointer;
  background: rgba(255,255,255,0.85); border: 2.5px solid var(--ink); border-radius: 50%; box-shadow: 2px 2px 0 var(--ink);
}
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; top: 12px; text-align: center; font-size: 22px; color: var(--ink); pointer-events: none; }
}
.icon-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0; }
.icon-btn i { display: block; width: 6px; height: 18px; background: var(--ink); border-radius: 2px; }
