@font-face {
  font-family: 'Goofy';
  src: url('../assets/fonts/MarajGoofyHand-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: block;
}
/* The Bold and ExtraBold cuts are deliberately NOT declared. Everything is
   set in Regular; where extra weight is wanted the canvas strokes the
   letterform (ui.js#text `medium`). This also keeps the ExtraBold face —
   whose "8" glyph is half-height — permanently out of reach. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

/* Measured by ui.js#readSafeArea. `padding` is a real property, so env()
   is guaranteed to be substituted here — unlike a custom property read
   back through getComputedStyle. */
#safe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  visibility: hidden;
  pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f4edda;
  position: fixed;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

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

#doodle-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: rgba(46, 41, 33, 0.58);
  font-family: Goofy, "Comic Sans MS", cursive;
  color: #2e2921;
  -webkit-user-select: none;
  user-select: none;
  /* Keep modal taps/cursor placement in the DOM layer instead of inheriting
     the canvas's gesture-only contract in older WKWebView releases. */
  touch-action: manipulation;
}

#doodle-dialog[hidden] { display: none; }

.doodle-dialog-card {
  width: min(100%, 350px);
  padding: 24px;
  border: 3px solid #2e2921;
  border-radius: 16px 13px 17px 14px;
  background: #fffdf4;
  box-shadow: 5px 7px 0 rgba(46, 41, 33, 0.18);
  transform: rotate(-0.35deg);
}

.doodle-dialog-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 400;
  text-align: center;
}

.doodle-dialog-card p {
  margin: 0 0 18px;
  color: rgba(46, 41, 33, 0.68);
  font-size: 16px;
  line-height: 1.25;
  text-align: center;
}

.doodle-dialog-card input,
.doodle-dialog-card select {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 2px solid rgba(46, 41, 33, 0.68);
  border-radius: 9px 11px 8px 10px;
  outline: none;
  background: #faf7ec;
  color: #2e2921;
  font: 400 20px Goofy, "Comic Sans MS", cursive;
  text-align: center;
}

.doodle-dialog-card input {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.doodle-dialog-card input:focus,
.doodle-dialog-card select:focus { border-color: #b97f14; }

.doodle-name-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.doodle-name-fields label,
.doodle-name-preview span {
  display: grid;
  gap: 5px;
  color: rgba(46, 41, 33, 0.68);
  font-size: 12px;
  text-align: center;
}

.doodle-name-preview {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
  padding: 9px 8px 7px;
  border: 2px dashed rgba(46, 41, 33, 0.3);
  border-radius: 10px 8px 11px 9px;
  text-align: center;
}

.doodle-name-preview output {
  overflow-wrap: anywhere;
  color: #2e2921;
  font-size: 19px;
}

.doodle-name-input {
  display: grid;
  gap: 6px;
}

.doodle-name-input > span,
.doodle-name-suggestions > span {
  color: rgba(46, 41, 33, 0.68);
  font-size: 12px;
  text-align: center;
}

.doodle-name-meta {
  display: flex;
  justify-content: space-between;
  margin: 5px 3px 12px;
  color: rgba(46, 41, 33, 0.62);
  font-size: 12px;
}

.doodle-name-meta output.over { color: #c04a3a; }

.doodle-dialog-card p.doodle-name-error {
  margin: -3px 0 11px;
  padding: 7px 9px;
  border-radius: 8px 10px 7px 9px;
  background: rgba(192, 74, 58, 0.1);
  color: #a63d31;
  font-size: 14px;
}

.doodle-name-suggestions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 14px;
}

.doodle-name-suggestions[hidden] { display: none; }

.doodle-name-suggestions > span { grid-column: 1 / -1; }

.doodle-name-suggestions button {
  min-width: 0;
  min-height: 38px;
  overflow: hidden;
  padding: 5px;
  border: 2px dashed rgba(185, 127, 20, 0.75);
  border-radius: 8px 10px 7px 9px;
  background: rgba(246, 224, 94, 0.22);
  color: #2e2921;
  font: 400 13px Goofy, "Comic Sans MS", cursive;
  text-overflow: ellipsis;
}

.doodle-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.doodle-dialog-actions.single { grid-template-columns: minmax(140px, 0.62fr); justify-content: center; }

.doodle-dialog-actions button {
  min-height: 48px;
  padding: 8px;
  border: 2px solid #2e2921;
  border-radius: 9px 11px 8px 10px;
  background: #fffdf4;
  color: #2e2921;
  font: 400 16px Goofy, "Comic Sans MS", cursive;
}

.doodle-dialog-actions button[type="submit"] {
  background: #f6e05e;
  border-color: #b97f14;
}

.doodle-dialog-actions button.danger {
  background: #c04a3a;
  border-color: #8f2f24;
  color: #fffdf4;
}

.doodle-dialog-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.doodle-moderation-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.doodle-moderation-actions button {
  min-height: 46px;
  padding: 8px;
  border: 2px solid #2e2921;
  border-radius: 9px 11px 8px 10px;
  background: #fffdf4;
  color: #2e2921;
  font: 400 16px Goofy, "Comic Sans MS", cursive;
}

.doodle-moderation-actions button:first-child { background: rgba(246, 224, 94, 0.38); }
.doodle-moderation-actions button:last-child { color: #a63d31; }
.doodle-moderation-actions button:disabled { color: rgba(46, 41, 33, 0.48); }

.doodle-dialog-card p.doodle-moderation-note {
  margin: 0 0 14px;
  font-size: 13px;
}

.doodle-report-reason {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  color: rgba(46, 41, 33, 0.68);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 360px), (max-height: 620px) {
  #doodle-dialog { padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
  .doodle-dialog-card { padding: 18px; }
  .doodle-dialog-card h2 { font-size: 21px; }
  .doodle-dialog-card p { margin-bottom: 13px; font-size: 14px; }
}
