@font-face {
  font-family: "Bangers";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/bangers-400.woff2") format("woff2");
}

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/fredoka.woff2") format("woff2");
}

:root {
  --navy: #062028;
  --navy-2: #0b3340;
  --navy-3: #0e4452;
  --gold: #f5d547;
  --gold-deep: #c9a018;
  --cream: #f4f1e8;
  --ink: #0b1420;
  --muted: #b7c6c8;
  --teal: #1a8a94;
  --cyan: #7ee8f0;
  --font-display: "Bangers", "Impact", "Haettenschweiler", "Arial Black", cursive;
  --font-ui: "Fredoka", "Segoe UI", "Trebuchet MS", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

button, a {
  font-family: inherit;
}

button { cursor: pointer; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: var(--ink);
  padding: 8px 12px;
  z-index: 20;
}
.skip-link:focus { left: 8px; }

.top-bar {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px 6px;
  background: linear-gradient(180deg, #08333c, var(--navy));
  border-bottom: 2px solid rgba(245, 213, 71, 0.35);
  flex: 0 0 auto;
}

.top-bar h1 {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5vw, 2rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 2px 2px 0 #021016;
}

.back-btn,
.save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  border: 2px solid var(--ink);
}

.back-btn {
  justify-self: start;
  background: rgba(11, 20, 36, 0.55);
  color: var(--cream);
  border-color: rgba(245, 213, 71, 0.45);
}

.save-btn {
  justify-self: end;
  background: linear-gradient(180deg, #fff4b0 0%, var(--gold) 50%, var(--gold-deep) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 #7a5a08;
}

.back-btn:focus-visible,
.save-btn:focus-visible,
.tool-btn:focus-visible,
.size-btn:focus-visible,
.action-btn:focus-visible,
.swatch:focus-visible,
.pick-btn:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.page-heading {
  flex: 0 0 auto;
  text-align: center;
  padding: 4px 12px 0;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4.4vw, 1.7rem);
  letter-spacing: 0.04em;
  color: #fff;
}

.hint {
  margin: 2px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.picker {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 10px 8px;
  scroll-snap-type: x mandatory;
}

.pick-btn {
  flex: 0 0 auto;
  width: 72px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  scroll-snap-align: start;
}

.pick-btn img {
  display: block;
  width: 100%;
  height: 86px;
  object-fit: cover;
  object-position: top;
}

.pick-btn.is-on {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px #021016, 0 0 0 5px var(--gold);
}

.pick-btn .pick-name {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.15;
  padding: 3px 4px 5px;
  color: var(--ink);
  background: #fff4c8;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #04181e;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.paper-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.paper {
  position: relative;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transform-origin: center center;
}

.paper canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#line-canvas {
  pointer-events: none;
  z-index: 2;
}

#fill-canvas {
  z-index: 1;
  touch-action: none;
}

.status {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.status.is-on { opacity: 1; }

.dock {
  flex: 0 0 auto;
  background: linear-gradient(180deg, var(--navy-2), #052026);
  border-top: 2px solid rgba(245, 213, 71, 0.35);
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tools,
.actions,
.size-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.tool-btn,
.action-btn,
.size-btn {
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #11414c;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1 1 0;
  max-width: 220px;
}

.tool-btn.is-on,
.size-btn.is-on {
  background: linear-gradient(180deg, #fff4b0, var(--gold));
  color: var(--ink);
}

.tool-icon { margin-right: 4px; }

.sizes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.sizes[hidden] {
  display: none !important;
}

.sizes-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
.dot-m { width: 12px; height: 12px; }
.dot-l { width: 16px; height: 16px; }

.palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 2px 2px 0;
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #021016;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), inset 0 -4px 0 rgba(0,0,0,0.15);
  padding: 0;
}

.swatch.is-on {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--gold);
}

.swatch.light {
  border-color: #888;
}

.action-btn.danger {
  background: #6b2430;
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.noscript-note {
  margin: 12px;
  text-align: center;
}

@media (min-width: 800px) {
  .pick-btn { width: 88px; }
  .swatch { width: 48px; height: 48px; }
  .back-btn, .save-btn { min-height: 48px; padding: 8px 16px; font-size: 1rem; }
}

@media (max-width: 500px) {
  .pick-btn { width: 64px; }
  .pick-btn img { height: 72px; }
}

@media (max-width: 400px) {
  .back-btn, .save-btn { font-size: 0.8rem; padding: 7px 8px; }
  .tool-btn, .action-btn, .size-btn { font-size: 0.85rem; min-height: 46px; padding: 7px 8px; }
  .swatch { width: 40px; height: 40px; }
}
