/* style.css — menus drawn to match the marker-on-paper look of the game. */

:root {
  --paper: #faf5e9;
  --ink: #1e1a17;
  --orange: #f4600f;
  --green: #1f8f3a;
  --blue: #1f6fd0;
  --yellow: #ffd919;
  --red: #e02316;
  --pink: #ff8fb8;
  --font: "Comic Sans MS", "Chalkboard SE", "Bradley Hand", "Segoe Print", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--paper);
  font-family: var(--font);
  color: var(--ink);
  /* Stop iPad rubber-banding and double-tap zoom while playing. */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------- screens */

.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(250, 245, 233, 0.93);
  z-index: 10;
  overflow-y: auto;
  animation: fadein .18s ease;
}
.screen.hidden { display: none; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  width: min(560px, 100%);
  text-align: center;
  padding: 22px 20px 26px;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 22px 30px 24px 34px / 30px 22px 34px 24px; /* hand-drawn wobble */
  box-shadow: 5px 6px 0 rgba(30,26,23,.16);
  max-height: 100%;
}
.sheet.wide { width: min(880px, 100%); }

h1.logo {
  margin: 0 0 6px;
  font-size: clamp(34px, 7.5vw, 62px);
  line-height: .92;
  letter-spacing: 1px;
  color: var(--orange);
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  transform: rotate(-2deg);
}
h1.logo b { color: var(--blue); font-size: 1.35em; display: inline-block; transform: rotate(2.5deg); }

h2 { margin: 0 0 14px; font-size: clamp(22px, 4.4vw, 32px); }

.title-ducks { width: 100%; max-width: 460px; height: auto; display: block; margin: 0 auto 6px; }

.hint { font-size: 15px; opacity: .8; margin: 12px 0 0; line-height: 1.45; }
.err { color: var(--red); min-height: 20px; margin: 6px 0 0; font-size: 14px; }

/* ------------------------------------------------------------- buttons */

button.big {
  display: block;
  width: 100%;
  margin: 9px 0;
  padding: 15px 18px;
  font-family: var(--font);
  font-size: clamp(18px, 3.4vw, 24px);
  font-weight: 900;
  color: var(--ink);
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 16px 22px 18px 24px / 22px 16px 24px 18px;
  box-shadow: 4px 5px 0 rgba(30,26,23,.85);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
button.big:active { transform: translate(4px, 5px); box-shadow: 0 0 0 rgba(0,0,0,0); }
button.big small { display: block; font-size: .6em; font-weight: 600; opacity: .75; margin-top: 2px; }
button.big.go   { background: var(--green); color: #fff; }
button.big.solo { background: var(--orange); color: #fff; }
button.big.host { background: var(--blue); color: #fff; }
button.big.join { background: var(--pink); width: auto; padding: 14px 26px; margin: 0; }
button.big.back { background: var(--paper); }

button.tiny {
  font-family: var(--font); font-size: 14px; font-weight: 700;
  background: none; border: 3px dashed var(--ink); border-radius: 12px;
  padding: 7px 14px; margin: 4px 0 10px; cursor: pointer; color: var(--ink);
}

.row { display: flex; gap: 12px; align-items: center; justify-content: center; }
.row button.big { flex: 1; }

/* --------------------------------------------------------- duck picker */

.ducks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.duckcard {
  border: 4px solid var(--ink);
  border-radius: 16px 22px 18px 24px / 22px 16px 24px 18px;
  background: var(--paper);
  padding: 8px 4px 10px;
  cursor: pointer;
  transition: transform .1s;
}
.duckcard canvas { width: 100%; max-width: 108px; height: auto; display: block; margin: 0 auto; }
.duckcard .nm { font-weight: 900; font-size: 17px; margin-top: 2px; }
.duckcard .tg { font-size: 11px; opacity: .7; line-height: 1.2; min-height: 26px; padding: 0 4px; }
.duckcard.sel { background: var(--yellow); transform: scale(1.05) rotate(-1.5deg); box-shadow: 4px 5px 0 rgba(30,26,23,.7); }
.duckcard.taken { opacity: .35; pointer-events: none; }

/* -------------------------------------------------------------- inputs */

.namebox { display: block; margin: 6px 0 14px; font-size: 15px; }
.namebox span { display: block; margin-bottom: 5px; opacity: .8; }
input {
  font-family: var(--font); font-weight: 900;
  font-size: clamp(20px, 4vw, 28px);
  text-align: center;
  text-transform: uppercase;
  padding: 11px 14px;
  width: 100%; max-width: 260px;
  border: 4px solid var(--ink);
  border-radius: 14px 18px 15px 20px / 18px 14px 20px 15px;
  background: #fff;
  color: var(--ink);
  letter-spacing: 3px;
}
#joincode { max-width: 170px; }
.joinbox { margin: 16px 0 8px; padding-top: 14px; border-top: 3px dashed rgba(30,26,23,.3); font-size: 15px; }
.joinbox > span { display: block; margin-bottom: 8px; opacity: .8; }

/* --------------------------------------------------------------- lobby */

.code {
  font-size: clamp(46px, 12vw, 84px);
  font-weight: 900;
  letter-spacing: 12px;
  color: var(--blue);
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  margin: 4px 0;
}
.lobby-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0; min-height: 60px; }
.lobby-list .who {
  border: 3px solid var(--ink); border-radius: 14px;
  padding: 7px 12px; font-weight: 900; font-size: 15px; background: #fff;
}

/* -------------------------------------------------------- pause / done */

.pausestat { font-size: 17px; line-height: 1.7; margin: 10px 0 16px; }
.pausestat b { color: var(--orange); font-size: 1.25em; }
#done-duck { width: 180px; height: 180px; display: block; margin: 0 auto; }

.help { margin-top: 16px; text-align: left; font-size: 15px; }
.help summary { cursor: pointer; font-weight: 900; padding: 8px; text-align: center; }
.help ul { margin: 6px 0 0; padding-left: 22px; line-height: 1.65; }

/* ------------------------------------------------------ toast / status */

.toast {
  position: fixed; left: 50%; top: 22%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 16px 22px 18px 24px / 22px 16px 24px 18px;
  box-shadow: 4px 5px 0 rgba(30,26,23,.5);
  padding: 12px 22px;
  font-weight: 900; font-size: clamp(16px, 3vw, 22px);
  text-align: center;
  max-width: 86vw;
  pointer-events: none;
  animation: pop .25s ease;
}
.toast.hidden { display: none; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0 } to { transform: translateX(-50%) scale(1); opacity: 1 } }

.netbadge {
  position: fixed; z-index: 15;
  right: max(8px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top));
  font-size: 12px; font-weight: 900;
  padding: 5px 11px;
  border: 3px solid var(--ink); border-radius: 12px;
  background: var(--paper);
}
.netbadge.hidden { display: none; }
.netbadge.warn { background: var(--yellow); }
.netbadge.bad  { background: var(--red); color: #fff; }

@media (max-height: 480px) {
  .sheet { padding: 14px 16px 16px; }
  button.big { padding: 11px 14px; margin: 6px 0; }
  h1.logo { font-size: clamp(26px, 6vw, 40px); }
  .title-ducks { max-width: 300px; }
}
