:root {
  --navy: #1c3a56;
  --tape: #d9c9a3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Fredoka', 'Baloo 2', sans-serif;
  background: linear-gradient(160deg, #8fe3d8 0%, #6fd0e0 35%, #4fa8dd 70%, #3f8fd4 100%);
  overflow-x: hidden;
}

.scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3vh, 56px) 16px;
}

.title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: var(--navy);
  font-size: clamp(36px, 5vw, 120px);
  margin: 8px 0 clamp(16px, 2vh, 40px);
  text-align: center;
  text-shadow: 0 2px 0 rgba(255,255,255,0.25);
}

.board {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.5vw, 48px);
  max-width: min(96vw, 2000px);
  width: 100%;
  justify-content: center;
}

.paper-wrap {
  position: relative;
  flex: 0 0 auto;
  height: clamp(420px, 78vh, 2200px);
}

.paper {
  position: relative;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 18px 40px rgba(0,20,40,0.35);
  height: 100%;
  width: auto;
  aspect-ratio: 892 / 1260;
  overflow: hidden;
  cursor: pointer;
}

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

#lineCanvas {
  pointer-events: none;
}

.tape {
  position: absolute;
  width: 70px;
  height: 34px;
  background: linear-gradient(120deg, rgba(233,220,190,0.92), rgba(210,192,152,0.92));
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  z-index: 5;
  opacity: 0.9;
}
.tape::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,0.15) 0 2px, transparent 2px 6px);
}
.tape-tl { top: -14px; left: -18px; transform: rotate(-42deg); }
.tape-tr { top: -14px; right: -18px; transform: rotate(42deg); }
.tape-bl { bottom: -14px; left: -18px; transform: rotate(42deg); }
.tape-br { bottom: -14px; right: -18px; transform: rotate(-42deg); }

.side-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
  padding-top: 4px;
}

.done-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.done-label {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: clamp(15px, 1.4vh, 24px);
  color: var(--navy);
  letter-spacing: 0.5px;
}

.done-btn {
  width: clamp(76px, 6vh, 130px);
  height: clamp(76px, 6vh, 130px);
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #2c5578, #0d2740 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0,10,25,0.45), inset 0 2px 4px rgba(255,255,255,0.15);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.done-btn:hover { transform: translateY(-2px) scale(1.03); }
.done-btn:active { transform: translateY(0) scale(0.97); }

.email-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: rgba(255,255,255,0.85);
  color: var(--navy);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: clamp(12.5px, 1.1vh, 18px);
  border-radius: 999px;
  padding: clamp(8px, 0.8vh, 14px) clamp(14px, 1.2vw, 22px);
  box-shadow: 0 4px 12px rgba(0,20,40,0.2);
  cursor: pointer;
  transition: transform 0.12s ease;
  max-width: clamp(140px, 11vw, 220px);
  text-align: center;
  line-height: 1.2;
}
.email-btn:hover { transform: translateY(-1px); }
.email-btn svg { flex: 0 0 auto; }

.palette-panel {
  background: rgba(255,255,255,0.85);
  border-radius: 22px;
  padding: clamp(14px, 1.4vh, 26px) clamp(12px, 1.2vw, 22px);
  box-shadow: 0 10px 24px rgba(0,20,40,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 1.2vh, 22px);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  font-weight: 700;
  color: var(--navy);
  font-size: clamp(14px, 1.3vh, 20px);
}
.pager-arrow {
  border: none;
  background: transparent;
  color: var(--navy);
  font-size: clamp(16px, 1.5vh, 24px);
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.pager-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}
.pager-count {
  min-width: clamp(56px, 5vw, 84px);
  text-align: center;
  font-size: clamp(10.5px, 1vh, 15px);
  line-height: 1.15;
  letter-spacing: 0.3px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(2, clamp(34px, 3.2vh, 56px));
  gap: clamp(8px, 0.8vh, 14px);
}

.swatch {
  width: clamp(34px, 3.2vh, 56px);
  height: clamp(34px, 3.2vh, 56px);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy), 0 2px 5px rgba(0,0,0,0.25);
  transform: scale(1.1);
}

.reset-btn {
  border: none;
  background: transparent;
  color: var(--navy);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: clamp(13px, 1.2vh, 18px);
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.75;
  padding: 2px 4px;
}
.reset-btn:hover { opacity: 1; }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 40, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.show { display: flex; }

.modal {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 28px 26px 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,10,25,0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #8a97a3;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--navy); }

.modal-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: var(--navy);
  font-size: 24px;
  margin: 0;
  text-align: center;
}

.modal-sub {
  margin: -8px 0 0;
  text-align: center;
  color: #5a6b7a;
  font-size: 14px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--navy);
  font-size: 13px;
}

.modal-field input {
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  font-weight: 400;
  padding: 10px 12px;
  border: 2px solid #dbe4ea;
  border-radius: 10px;
  outline: none;
  color: #1c2b38;
}
.modal-field input:focus { border-color: #4fa8dd; }

.modal-error {
  margin: -4px 0 0;
  color: #c62828;
  font-size: 13px;
  font-weight: 600;
  min-height: 16px;
  text-align: center;
}

.modal-send-btn {
  border: none;
  background: radial-gradient(circle at 35% 30%, #2c5578, #0d2740 75%);
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 17px;
  padding: 13px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,10,25,0.35);
  transition: transform 0.12s ease;
}
.modal-send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.modal-send-btn:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 760px) {
  .board { flex-direction: column; align-items: center; }
  .paper-wrap { flex: 1 1 auto; width: 100%; max-width: 420px; height: auto; }
  .paper { width: 100%; height: auto; }
  .side-controls { flex-direction: row-reverse; align-items: center; justify-content: center; width: 100%; max-width: 420px; }
  .palette-panel { flex: 1; }
}
