:root {
  --ink: #5a3825;
  --cream: #fffaf2;
  --font: 'M PLUS Rounded 1c', 'Jua', 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #aef0dd; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); touch-action: none; word-break: keep-all; overflow-wrap: anywhere; }
input { -webkit-user-select: text; user-select: text; touch-action: auto; }

#scene { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; }
#stage { position: fixed; left: 0; top: 0; width: 360px; height: 640px; transform-origin: 0 0; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font: 800 18px/1 var(--font); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 999px;
  background: linear-gradient(#ffffff 55%, #ffe6f1);
  box-shadow: 0 5px 0 var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; height: 50px; cursor: pointer; white-space: nowrap;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn svg { width: 20px; height: 20px; display: block; }
.btn .ic { display: inline-flex; }
.btn.small { height: 40px; font-size: 14px; padding: 0 12px; }
.btn.small.icon { width: 40px; padding: 0; }
.top-left { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
/* top right: the 🔊 that switches the tap sound; before the menu is on the phone's home screen,
   "add to Home" shows next to it (smaller, and the name button leaves it room) */
.top-right { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.btn.off { opacity: .55; }
#btn-install { max-width: 118px; padding: 0 10px 0 8px; gap: 4px; font-size: 12px; line-height: 1.1; white-space: normal; word-break: keep-all; text-align: left; }
#stage:has(#btn-install:not([hidden])) .user-btn { max-width: 118px; }
.user-btn { max-width: 170px; gap: 6px; padding: 0 12px 0 8px; }
.user-btn #user-label { overflow: hidden; text-overflow: ellipsis; }
.udot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--ink); flex: none; }

/* the whole menu scrolls: logo, the island (drawn on the canvas behind) and the games */
.scroller { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.island-space { height: 158px; }

/* ---------- title ---------- */
.logo { position: relative; margin: 0; padding-top: 58px; text-align: center; font-weight: 800; line-height: 1.02; }
.logo span { display: block; }
.logo b {
  display: inline-block; font-size: 60px; font-weight: 800; color: #fff;
  -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill;
  animation: hop 2.6s ease-in-out infinite; animation-delay: calc(var(--d) * .12s);
}
.logo .l2 b { font-size: 64px; }
.logo.latin b { font-size: 58px; }
.logo.latin .l2 b { font-size: 62px; }
.logo b.gap { width: .3em; }
.sub {
  position: relative; margin: 16px auto 0; width: max-content; max-width: 330px; text-align: center;
  padding: 7px 16px; font-size: 16px; font-weight: 800;
  background: rgba(255, 255, 255, .88); border: 3px solid var(--ink); border-radius: 999px;
}

/* ---------- games ---------- */
.games {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 214px; gap: 12px;
  padding: 2px 14px 28px;
}
.games::-webkit-scrollbar { display: none; }
.game {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 12px 6px 10px; text-decoration: none; color: var(--ink); cursor: pointer;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink);
  transition: transform .06s ease-out, box-shadow .06s ease-out;
}
.game:active, .game.go { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.game img {
  width: 124px; height: 124px; border-radius: 28px; display: block;
  border: 3px solid var(--ink); background: #fff; box-shadow: 0 3px 0 rgba(90, 56, 37, .25);
}
.game-name { font-size: 17px; font-weight: 800; line-height: 1.25; text-align: center; white-space: pre-line; }
.game { position: relative; }
.game-ver { position: absolute; right: 13px; bottom: 7px; font-size: 11px; font-weight: 800; opacity: .55; }
.land-ver { position: relative; margin: -16px 0 22px; text-align: center; font-size: 12px; font-weight: 800; opacity: .6; min-height: 14px; }

@keyframes hop { 0%, 55%, 100% { transform: translateY(0); } 25% { transform: translateY(-9px) rotate(-5deg); } 40% { transform: translateY(1px); } }

/* ---------- nickname ---------- */
.panel {
  position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center;
  padding-top: 130px; background: rgba(90, 56, 37, .18);
}
.panel.on { display: flex; }
.panel-card {
  width: 306px; padding: 18px 16px 22px; background: var(--cream); display: flex; flex-direction: column; gap: 12px;
  border: 4px solid var(--ink); border-radius: 30px; box-shadow: 0 8px 0 rgba(90, 56, 37, .35); text-align: center;
}
.panel-title { font-size: 20px; font-weight: 800; }
.panel-note { margin: -6px 0 0; font-size: 14px; font-weight: 800; opacity: .75; }
.name-input { font: 800 22px var(--font); color: var(--ink); padding: 8px 12px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; width: 100%; }
.panel-row { display: flex; justify-content: center; gap: 12px; }
.btn.ok { background: linear-gradient(#e2f9d3, #a9e38a); min-width: 110px; }

/* ---------- language ---------- */
.lang-list { display: flex; flex-direction: column; gap: 10px; padding: 2px 10px 6px; }
.lang-item { height: 52px; font-size: 21px; }
.lang-item.on { background: linear-gradient(#e2f9d3, #a9e38a); }
.lang-item.on::after { content: "✓"; margin-left: 4px; }

/* ---------- players (shared by every game) ---------- */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 8px; }
.user-pick { flex: 1; min-width: 0; height: 54px; justify-content: flex-start; gap: 8px; padding: 0 10px; font-size: 18px; }
.user-pick .udot { width: 26px; height: 26px; }
.user-pick .uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pick small { margin-left: auto; flex: none; font-size: 11px; opacity: .7; }
.user-pick.on { background: linear-gradient(#fff6b8, #ffd84d); }
.user-edit { flex: none; }
.add-btn { height: 46px; font-size: 16px; gap: 6px; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; height: 44px; cursor: pointer; font: 800 17px/1 var(--font); color: var(--ink);
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
}
.seg button.on { background: linear-gradient(#fff6b8, #ffd84d); }
.swatches { display: flex; gap: 8px; justify-content: center; }
.swatches button { width: 34px; height: 34px; padding: 0; cursor: pointer; border-radius: 50%; border: 3px solid var(--ink); }
.swatches button.on { outline: 3px solid #ff6fa8; outline-offset: 2px; }
.del-btn { align-self: center; height: 38px; font-size: 14px; }

/* ---------- moving to the new address (js/move.js) ---------- */
.move-panel { padding-top: 112px; z-index: 5; }
.move-note { margin: 0; line-height: 1.45; white-space: normal; }
.move-addr {
  align-self: center; padding: 6px 14px; font-size: 17px; font-weight: 800; letter-spacing: .02em;
  background: #fff; border: 3px dashed var(--ink); border-radius: 14px;
}
.move-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 4px; }
.move-go { height: 58px; font-size: 21px; padding: 0 24px; }
.move-again { opacity: .8; }
