/* =====================================================================
   Photobashed - the look of the whole site.
   Based on the logo: pastel colours with bold black outlines.
   ===================================================================== */

:root {
  --ink: #1d1b22; /* outlines and text */
  --paper: #fffdf8; /* cards and buttons */
  --cream: #f7f1e3; /* the page */
  --pink: #ffd3d3;
  --green: #e3fbc6;
  --blue: #a9d3ff;
  --lilac: #f1d6ff;
  --purple: #c49cff;
  --muted: #6b6573;
  --red: #d63c3c;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-small: 2px 2px 0 var(--ink);
  --round: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background-color: var(--cream);
  /* faint polka dots */
  background-image: radial-gradient(rgba(29, 27, 34, 0.07) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1,
h2,
h3,
h4 {
  font-weight: 900;
  margin: 0 0 10px;
}

h2 {
  font-size: 1.35rem;
}

a {
  color: #6a3fd1;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-weight: 600;
}

.center {
  text-align: center;
}

.error {
  color: var(--red);
  font-weight: 800;
  min-height: 1.5em;
  margin: 8px 0 0;
}

.row {
  display: flex;
  gap: 8px;
}

/* ----- The logo ----- */

.logo {
  display: block;
  width: min(560px, 92%);
  margin: 4px auto 14px;
}

.logo.small {
  width: 100%;
  margin: 0 0 12px;
}

.tagline {
  text-align: center;
  font-size: 1.1rem;
  max-width: 900px;
  margin: 0 auto 22px;
}

/* ----- Cards: white boxes with a black outline and a chunky shadow ----- */

.card {
  background: var(--paper);
  border: var(--line);
  border-radius: 18px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 20px;
}

/* ----- Form controls ----- */

label,
.label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

input,
textarea,
select {
  font-family: inherit;
  font-weight: 700;
  color: var(--ink);
}

input:not([type]),
input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.1rem;
  background: white;
  border: var(--line);
  border-radius: 12px;
  outline: none;
}

input:not([type]):focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px var(--purple);
}

textarea {
  resize: vertical;
}

select {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  background: white;
  border: var(--line);
  border-radius: 10px;
}

input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--purple);
}

input[type="range"] {
  accent-color: #8f5cf0;
}

/* ----- Buttons: pastel with a black outline, pressed in when tapped ----- */

button {
  padding: 11px 18px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ink);
  background: var(--purple);
  border: var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-small);
  cursor: pointer;
  touch-action: manipulation; /* no zooming in when a button is tapped twice quickly */
  transition: transform 0.05s, box-shadow 0.05s, background 0.15s;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

button.secondary {
  background: var(--paper);
}

button.pink {
  background: var(--pink);
}

button.green {
  background: var(--green);
}

button.blue {
  background: var(--blue);
}

button.purple {
  background: var(--purple);
}

button.big {
  font-size: 1.25rem;
  padding: 14px 20px;
  box-shadow: var(--shadow);
}

button.small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

button.icon {
  min-width: 44px;
  padding: 6px;
  font-size: 1.25rem;
}

#create-button,
#leave-button,
#start-button,
#done-button,
#next-button {
  width: 100%;
  margin-top: 14px;
}

/* ----- Home screen ----- */

.home-grid,
.notes-grid,
.lobby-grid {
  display: grid;
  gap: 20px;
}

.notes-grid {
  margin-top: 24px;
}

@media (min-width: 800px) {
  .home-grid {
    grid-template-columns: 1fr 1fr;
  }
  .notes-grid {
    grid-template-columns: 1.2fr 1.4fr 1fr;
  }
  .lobby-grid {
    grid-template-columns: 1.2fr 1fr;
    align-items: start;
  }
}

.play-card {
  background: var(--lilac);
}

.play-card input {
  margin-bottom: 4px;
}

#code-input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.2em;
}

#join-button {
  white-space: nowrap;
}

/* "or join a friend's room" with a line on each side */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  margin: 22px 0 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 2px dashed rgba(29, 27, 34, 0.35);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.step-dot {
  flex: none;
  width: 30px;
  height: 30px;
  border: var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.9rem;
}

.step-dot.blue { background: var(--blue); }
.step-dot.green { background: var(--green); }
.step-dot.pink { background: var(--pink); }
.step-dot.purple { background: var(--purple); }

.note-card {
  padding: 16px 18px;
  font-size: 0.95rem;
}

.note-card:nth-child(1) { background: var(--pink); }
.note-card:nth-child(2) { background: var(--green); }
.note-card:nth-child(3) { background: var(--blue); }

.note-card ul {
  margin: 0;
  padding-left: 18px;
}

.note-card li {
  margin-bottom: 6px;
}

.note-card p {
  margin: 0 0 6px;
}

.note-card .hint {
  color: #4a4552;
}

/* ----- Lobby ----- */

.room-code {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  text-align: center;
  margin: 0 0 6px;
  padding: 6px 0 6px 0.25em;
  background: var(--blue);
  border: var(--line);
  border-radius: var(--round);
  box-shadow: var(--shadow);
}

.lobby-grid h2 {
  margin-top: 18px;
}

.lobby-grid .card > h2:first-child {
  margin-top: 0;
}

.count-pill {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 8px;
  margin-left: 4px;
  text-align: center;
  font-size: 0.95rem;
  background: var(--green);
  border: 2px solid var(--ink);
  border-radius: 999px;
}

#player-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  margin-bottom: 8px;
  min-height: 50px;
  font-size: 1.05rem;
}

#player-list li:nth-child(4n + 1) { background: var(--lilac); }
#player-list li:nth-child(4n + 2) { background: var(--green); }
#player-list li:nth-child(4n + 3) { background: var(--pink); }
#player-list li:nth-child(4n + 4) { background: var(--blue); }

/* A player who lost connection and might come back */
#player-list li.away {
  opacity: 0.5;
}

.tag {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 6px;
}

.setting {
  font-weight: 800;
  margin-bottom: 14px;
}

.setting select {
  margin-top: 6px;
}

.setting-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
  font-weight: 800;
  margin-bottom: 12px;
}

.setting-check input {
  width: 22px;
  height: 22px;
}

.setting-check .hint {
  grid-column: 2;
  font-size: 0.85rem;
}

/* ----- Writing a prompt / describing a picture ----- */

.write-card {
  max-width: 1000px;
  margin: 0 auto;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.step-row .step-pill {
  flex: 1;
}

.step-pill {
  display: inline-block;
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}

/* The picture you have to describe: big, filling most of the screen */
#write-screen #previous-entry img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  width: auto;
  margin: 0 auto;
  border: var(--line);
  border-radius: var(--round);
}

#previous-entry {
  margin-bottom: 14px;
}

/* A text entry (a prompt or a description) */
.text-entry {
  background: white;
  border: var(--line);
  border-radius: var(--round);
  padding: 14px 16px;
  font-size: 1.25rem;
  margin: 0;
}

/* A picture that's missing (e.g. a player left), shown as text */
.image-entry {
  background: var(--lilac);
  border: 3px dashed var(--ink);
  border-radius: var(--round);
  padding: 24px 12px;
  font-size: 1.2rem;
  font-style: italic;
  text-align: center;
  margin: 0;
}

/* A finished picture, shown to the next player and in the reveal */
.entry-image {
  display: block;
  width: 100%;
  border: var(--line);
  border-radius: var(--round);
}

/* ----- Waiting for the others ----- */

.waiting-card {
  max-width: 520px;
  margin: 40px auto 0;
  text-align: center;
  background: var(--green);
}

.bouncy {
  font-size: 3.5rem;
  animation: bounce 1.2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ----- Timer ----- */

.timer {
  font-weight: 900;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums; /* digits all the same width, so it doesn't wiggle */
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}

.timer:empty {
  display: none;
}

.timer.urgent {
  background: var(--pink);
  color: var(--red);
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  to { transform: scale(1.08); }
}

/* ----- Streamer mode: blurred until the host taps "Peek" ----- */

.streamer-blur:not(.peeked) {
  filter: blur(22px);
  cursor: pointer;
}

#moderation-panel {
  margin-top: 16px;
  background: var(--lilac);
}

#moderation-entry {
  margin: 10px 0 14px;
  max-height: 50vh;
  overflow: hidden;
}

#moderation-entry img {
  max-height: 46vh;
  width: auto;
  max-width: 100%;
}

#moderation-panel .row button {
  flex: 1;
}

/* ----- While editing and during the reveal, use the whole screen ----- */

main.wide {
  max-width: none;
  padding: 8px 12px;
}

main.wide > .logo {
  display: none;
}

/* =====================================================================
   The image editor
   ===================================================================== */

/* Top bar: step, prompt, timer, Done */
.draw-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.draw-prompt-box {
  flex: 1;
  min-width: 0;
  margin: 0;
  background: var(--paper);
  border: var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 1.15rem;
}

.draw-prompt-box .hint {
  font-size: 0.85rem;
}

#draw-done-button {
  padding: 10px 24px;
  background: var(--green);
  box-shadow: var(--shadow);
}

.draw-header button.icon {
  min-height: 42px;
}

/* The three columns: tools | canvas | selected image + layers */
.tools-panel,
.layers-panel {
  user-select: none; /* so dragging a slider can't accidentally drag selected text */
  -webkit-user-select: none;
}

.editor-main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#canvas-area {
  position: relative;
  border: var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none; /* stop the phone from scrolling/zooming the page while editing */
  user-select: none; /* holding a finger on the canvas shouldn't select text... */
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* ...or pop up the "save image" menu on iPhones */
}

/* The circle that shows the brush size while painting */
#brush-cursor {
  position: absolute;
  pointer-events: none;
  border: 1px solid black;
  box-shadow: 0 0 0 1px white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#draw-error:empty {
  display: none;
}

#draw-error {
  margin: 6px 0 0;
  min-height: 0;
}

/* The tip shown in the middle of the canvas while it's still empty */
#canvas-hint {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #9a93a3;
  font-weight: 800;
  pointer-events: none; /* clicks go straight through to the canvas */
}

/* Tool buttons (Move, Brush, Eraser, ...) */
.tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

button.tool {
  padding: 8px 8px;
  font-size: 0.95rem;
  background: var(--paper);
  white-space: nowrap;
}

button.tool.active {
  background: var(--purple);
}

/* The little keyboard-shortcut number on each tool button */
button.tool .key {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 6px;
  padding: 0 4px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: white;
  font-size: 0.7rem;
  text-align: center;
}

/* The two smaller extra tools (blur and sharpen brushes) */
.mini-tools {
  display: flex;
  flex-wrap: wrap; /* (one under the other when the column is narrow) */
  gap: 6px;
  margin-top: 8px;
}

button.tool.mini {
  flex: 1 1 70px;
  padding: 4px 6px;
  font-size: 0.8rem;
  text-align: center;
  box-shadow: none;
  border-width: 2px;
}

button.tool.mini .key {
  margin-right: 3px;
  font-size: 0.65rem;
}

.action-buttons {
  display: flex;
  gap: 6px;
  margin: 12px 0;
}

.action-buttons #upload-button {
  flex: 1;
  padding: 8px;
  font-size: 0.95rem;
}

.tool-options,
.panel {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--round);
  padding: 12px;
}

.panel + .panel {
  margin-top: 14px;
}

#tool-hint {
  margin: 0 0 10px;
  font-size: 0.88rem;
}

.mode-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.mode-buttons button {
  flex: 1;
  padding: 8px 4px;
  font-size: 0.9rem;
  background: var(--paper);
  box-shadow: none;
  border-width: 2px;
}

.mode-buttons button.active {
  background: var(--blue);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  margin-bottom: 8px;
}

#text-options select {
  margin-top: 4px;
}

#text-options button,
#crop-options button,
#clone-options button {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  font-size: 1rem;
}

/* Text tool: a sample of how the text will look */
#text-preview {
  margin: 6px 0 10px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: repeating-conic-gradient(#ddd 0% 25%, #f4f4f4 0% 50%) 50% / 16px 16px; /* checkerboard */
  font-size: 34px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  paint-order: stroke fill; /* outline behind the letters, like the real text */
}

.layers-panel h3 {
  margin: 0 0 10px;
}

.panel-subhead {
  margin: 16px 0 6px;
  padding-top: 10px;
  border-top: 2px dashed rgba(29, 27, 34, 0.25);
}

.small-print {
  font-size: 0.8rem;
  margin: 2px 0 0;
}

/* ----- Editing tools for the selected image ----- */

#remove-bg-button {
  width: 100%;
}

#bg-status {
  margin: 6px 0;
  min-height: 1.2em;
  font-size: 0.85rem;
}

.slider {
  display: block;
  font-weight: 800;
  margin-bottom: 4px;
}

.slider .hint {
  font-size: 0.8rem;
}

.slider input[type="range"] {
  display: block;
  width: 100%;
  height: 30px; /* tall enough to grab with a finger */
  margin: 0;
}

.tint-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tint-row input[type="range"] {
  flex: 1;
}

/* Two buttons side by side (Duplicate + Merge, the two Flips) */
.flip-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.flip-row button {
  flex: 1;
  padding: 9px 6px;
  font-size: 0.95rem;
}

#reset-effects-button {
  margin-top: 8px;
}

/* ----- Layers list ----- */

.layer-opacity {
  margin-bottom: 8px;
}

#layer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* One row in the layers panel */
.layer {
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 6px;
  cursor: pointer;
}

.layer.selected {
  background: var(--lilac);
  box-shadow: inset 0 0 0 2px var(--purple);
}

.layer.hidden-layer img,
.layer.hidden-layer .layer-name {
  opacity: 0.35;
}

.layer img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: repeating-conic-gradient(#e6e6e6 0% 25%, #fafafa 0% 50%) 50% / 10px 10px;
  border-radius: 6px;
}

.layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The small buttons in each layer row, big enough to tap */
.layer button {
  min-width: 40px;
  min-height: 38px;
  padding: 4px;
  font-size: 0.85rem;
  background: var(--paper);
  border-width: 2px;
  box-shadow: none;
}

.layer-grip {
  cursor: grab;
  color: var(--muted);
  padding: 8px 2px;
  touch-action: none; /* on phones, dragging the grip moves the layer instead of scrolling */
}

.layer.dragging {
  position: relative;
  z-index: 10;
  opacity: 0.9;
  box-shadow: var(--shadow);
}

.layer.drop-above {
  box-shadow: 0 -4px 0 var(--purple);
}

.layer.drop-below {
  box-shadow: 0 4px 0 var(--purple);
}

/* --- Wide screens (computers, tablets and phones turned sideways): like Gartic Phone,
       tools on the left, canvas in the middle, layers on the right, filling the screen.
       (This rule must match WIDE_LAYOUT in editor.js.) --- */
@media (min-width: 700px) and (orientation: landscape) {
  #draw-screen:not([hidden]) {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 16px);
  }

  .editor-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 280px;
    grid-template-rows: minmax(0, 1fr);
    gap: 14px;
    margin-top: 10px;
  }

  .tools-panel,
  .layers-panel {
    overflow-y: auto; /* each side scrolls by itself if it doesn't fit */
    min-height: 0;
    padding: 2px 6px 6px 2px; /* room for the outlines and shadows */
  }

  /* Leave room at the bottom for the "Leave game" button */
  .tools-panel {
    padding-bottom: 60px;
  }

  /* Tools stacked on top of each other, one per row */
  .tool-buttons {
    grid-template-columns: 1fr;
  }

  button.tool:not(.mini) {
    text-align: left;
    padding: 10px 12px;
    font-size: 1rem;
  }

  .action-buttons {
    flex-wrap: wrap;
  }

  .action-buttons #upload-button {
    flex-basis: 100%;
    padding: 12px;
  }

  .action-buttons button.icon {
    flex: 1;
  }

  .editor-main {
    min-height: 0;
    overflow: hidden;
    justify-content: center;
    padding: 4px 8px 8px 4px; /* room for the canvas shadow */
  }

  #rotate-hint {
    display: none;
  }
}

/* Smaller wide screens (small laptops, phones turned sideways): slimmer side panels. */
@media (min-width: 700px) and (max-width: 1100px) and (orientation: landscape) {
  .editor-body {
    grid-template-columns: 160px minmax(0, 1fr) 230px;
    gap: 10px;
  }
}

/* --- Narrow screens (phones held upright): everything stacked. The top bar and the canvas
       stay stuck to the top while you scroll down to the tools. --- */
@media not all and (min-width: 700px) and (orientation: landscape) {
  .editor-body {
    display: flex;
    flex-direction: column;
  }

  .draw-header {
    position: sticky;
    top: 0;
    z-index: 6;
    padding: 4px 0;
    background: var(--cream);
  }

  .editor-main {
    order: 1;
    position: sticky;
    top: var(--header-height, 0px);
    z-index: 5;
    background: var(--cream);
    padding: 4px 0 8px;
  }

  .tools-panel {
    order: 2;
  }

  .layers-panel {
    order: 3;
    margin-top: 14px;
  }

  /* Tool buttons in one row you can swipe sideways */
  .tool-buttons {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  button.tool {
    flex: none;
  }

  #rotate-hint {
    margin: 6px 0 0;
    font-size: 0.85rem;
  }

  .draw-prompt-box {
    font-size: 1rem;
    padding: 6px 10px;
  }

  .step-pill {
    display: none; /* no room on narrow screens */
  }

  .write-card .step-pill {
    display: inline-block;
  }
}

/* =====================================================================
   The reveal
   ===================================================================== */

.reveal-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.reveal-sidebar h3 {
  margin: 0 0 8px;
}

#reveal-owners {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#reveal-owners li {
  background: white;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
}

#reveal-owners li.current {
  background: var(--purple);
  box-shadow: var(--shadow-small);
}

#reveal-owners li.seen {
  background: var(--green);
  opacity: 0.7;
}

.reveal-main {
  flex: 1;
  min-width: 0;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.reveal-main h2 {
  font-size: 1.7rem;
}

.reveal-entry {
  margin-bottom: 20px;
  animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
  from { transform: scale(0.95); opacity: 0; }
}

.reveal-entry .who {
  font-weight: 900;
  font-size: 1.1rem;
  margin: 0 0 6px;
}

#reveal-screen .text-entry,
#reveal-screen .image-entry {
  font-size: 1.7rem;
  padding: 18px 22px;
}

.save-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9rem;
}

@media (min-width: 700px) {
  .reveal-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .reveal-sidebar {
    width: 230px;
    position: sticky;
    top: 8px;
  }

  #reveal-owners {
    flex-direction: column;
  }
}

/* =====================================================================
   Bits that float on top
   ===================================================================== */

/* Connection lost */
#connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 10px;
  text-align: center;
  font-weight: 900;
  background: var(--pink);
  border-bottom: var(--line);
}

/* "Leave game" / "End game", tucked in the bottom-left corner during a game */
#leave-game-button {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
}

/* "2/4" in the bottom-right corner: how many players have finished this step */
#progress-badge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  padding: 6px 14px;
  border: var(--line);
  border-radius: 999px;
  background: var(--blue);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-small);
}

/* On narrow screens there's no spare corner, so "Leave game" goes at the very bottom instead. */
@media not all and (min-width: 700px) and (orientation: landscape) {
  #leave-game-button {
    position: static;
    display: block;
    margin: 0 auto 24px;
  }

  main {
    padding-bottom: 16px;
  }
}

/* ----- Help window ----- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(29, 27, 34, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  position: relative;
  background: var(--paper);
  border: var(--line);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 22px 26px;
  max-width: 680px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.modal-box h3 {
  margin: 18px 0 6px;
}

.modal-box ul {
  margin: 0;
  padding-left: 20px;
}

.modal-box li {
  margin-bottom: 5px;
}

#help-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

table.keys {
  border-collapse: collapse;
  width: 100%;
}

table.keys td {
  padding: 5px 8px;
  border-bottom: 2px dashed rgba(29, 27, 34, 0.15);
}

table.keys td:first-child {
  font-weight: 900;
  white-space: nowrap;
}

/* =====================================================================
   Round of polish
   ===================================================================== */

/* ----- Home: the heads-up box and the small Credits / Contact buttons ----- */

.note-card {
  margin-top: 22px;
  background: var(--pink);
}

.small-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.small-links button {
  padding: 9px 18px;
  font-size: 1rem;
}

/* ----- Symbols lined up: each symbol sits in a box of the same width ----- */

.ico {
  display: inline-block;
  width: 1.5em;
  text-align: center;
  margin-right: 4px;
}

/* ----- Editor: a more compact tools column, so the tool settings fit without scrolling ----- */

.tool-buttons {
  gap: 5px;
}

button.tool {
  display: flex;
  align-items: center;
}

/* Blur and Sharpen share one button, split in half */
.split-tool {
  display: flex;
  border: var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-small);
  overflow: hidden;
}

.split-tool button.tool {
  flex: 1;
  justify-content: center;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 7px 4px;
  font-size: 0.85rem;
}

.split-tool button.tool + button.tool {
  border-left: 2px solid var(--ink);
}

.split-tool button.tool .key {
  margin-right: 4px;
}

.split-tool button.tool:active {
  transform: none;
}

@media (min-width: 700px) and (orientation: landscape) {
  button.tool:not(.mini) {
    padding: 6px 10px;
    font-size: 0.95rem;
  }

  .split-tool button.tool:not(.mini) {
    padding: 6px 4px;
    font-size: 0.82rem;
    justify-content: center;
  }

  /* Add image + undo + redo in one row */
  .action-buttons {
    flex-wrap: nowrap;
    margin: 10px 0;
  }

  .action-buttons #upload-button {
    flex: 1;
    flex-basis: auto;
    padding: 8px 6px;
    font-size: 0.9rem;
  }

  .action-buttons button.icon {
    flex: none;
    min-width: 40px;
  }
}

/* On phones the split button sits in the swipeable row like the others */
@media not all and (min-width: 700px) and (orientation: landscape) {
  .split-tool {
    flex: none;
  }
}

#perspective-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#perspective-options button {
  flex: 1;
}

/* ----- Bigger small buttons ----- */

#leave-game-button {
  padding: 10px 20px;
  font-size: 1rem;
}

#player-list li button,
.reveal-kick {
  padding: 8px 14px;
  font-size: 0.95rem;
}

.layer button {
  min-width: 44px;
  min-height: 40px;
}

/* ----- Reveal: a bigger players box ----- */

@media (min-width: 700px) {
  .reveal-sidebar {
    width: 300px;
  }
}

.reveal-sidebar h3 {
  font-size: 1.3rem;
}

#reveal-owners li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  font-size: 1.1rem;
}

/* ----- Credits and Contact windows ----- */

.small-box {
  max-width: 520px;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* Contact: a purple header strip, like a notepad */
.contact-box {
  padding: 0;
  overflow: hidden;
}

.contact-header {
  position: relative;
  background: #7a4cf0;
  border-bottom: var(--line);
  padding: 18px 60px;
  text-align: center;
}

.contact-header h2 {
  margin: 0;
  font-size: 1.8rem;
  color: white;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
  letter-spacing: 0.04em;
}

.contact-header .close-button {
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  box-shadow: none;
  color: white;
  font-size: 1.6rem;
}

#contact-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 26px 26px;
}

#contact-form input,
#contact-form textarea {
  background: #f4f2f8;
}

#contact-send {
  align-self: center;
  min-width: 180px;
  background: #8f5cf0;
  color: white;
}

#contact-status:empty {
  display: none;
}

#contact-status {
  margin: 0;
  font-weight: 800;
}

/* The hidden box that only spam robots fill in */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Wide screens: tighter tools column, so the tool's settings fit on the screen without scrolling */
@media (min-width: 700px) and (orientation: landscape) {
  .tool-buttons {
    gap: 3px;
  }

  button.tool:not(.mini) {
    padding: 3px 10px;
    font-size: 0.92rem;
  }

  .split-tool button.tool:not(.mini) {
    padding: 4px;
    font-size: 0.8rem;
  }

  .action-buttons {
    margin: 8px 0;
  }

  .action-buttons #upload-button {
    padding: 6px;
  }

  .action-buttons button.icon {
    min-width: 38px;
    padding: 4px;
    font-size: 1.1rem;
  }

  .tool-options {
    padding: 10px;
  }

  #tool-hint {
    font-size: 0.8rem;
    line-height: 1.25;
    margin-bottom: 6px;
  }

  .tool-options .slider {
    font-size: 0.9rem;
    margin-bottom: 0;
  }

  .tool-options .slider input[type="range"] {
    height: 24px;
  }

  .tool-options .color-row {
    margin-bottom: 4px;
  }
}

/* Lobby: the little explanation under "Extra rounds" */
.setting-hint {
  margin: -4px 0 10px;
  font-size: 0.85rem;
}

/* Twist mode: picking the photo to start with */
#twist-photo {
  border: 3px dashed var(--ink);
  border-radius: 14px;
  background: var(--paper);
  padding: 12px;
  margin-bottom: 12px;
  text-align: center;
}

#twist-preview {
  display: block;
  max-width: 100%;
  max-height: 240px;
  margin: 0 auto 10px;
  border-radius: 8px;
}

.twist-words {
  margin-top: 8px;
}

/* Credits: who made it */
.made-by {
  font-size: 1.15rem;
}

/* Twist photos can be any shape (like a tall phone photo), so don't let them get huge */
.entry-image:has(+ .twist-words) {
  width: auto;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
}

/* Wide screens: the line under the logo stays on one line */
@media (min-width: 900px) {
  .tagline {
    white-space: nowrap;
  }
}
