:root {
  --bg: #f4efe6;
  --ink: #2f2c28;
  --ridge: #4a4742;
  --mute: #8d877c;
  --hint: #9a9388;
  --line: #ddd6c8;
  --glow: #f4f1ea;
  --btn: #ece7dc;
  --app-height: 100vh;
  --safe-top: 0px;
  --safe-bottom: 0px;
}

html {
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 100%;
  min-height: 100vh;
  min-height: var(--app-height, 100vh);
  padding-top: 14px;
  padding-top: calc(14px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  padding-bottom: 18px;
  padding-bottom: calc(18px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  background: var(--bg);
  transition: background-color 420ms ease, color 420ms ease;
}

.app.is-dark {
  --bg: #0b0b0c;
  --ink: #f3f1ec;
  --ridge: #cfcac0;
  --mute: #8a8680;
  --hint: #6f6c67;
  --line: #2a2a2c;
  --btn: #1a1a1c;
}

.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  align-self: stretch;
  width: 100%;
  padding-left: 22px;
  padding-right: 18px;
  min-height: 36px;
}

.app.is-session .brand,
.app.is-session .ghost-btn {
  opacity: 0;
  pointer-events: none;
}

.brand {
  font-size: 15px;
  letter-spacing: 0.18em;
  font-weight: 500;
  color: var(--mute);
}

.ghost-btn {
  display: block;
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 1px solid #8d877c;
  border-radius: 50%;
  background: #f4efe6;
  color: #6f6a62;
  font-size: 13px;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 26px;
  text-align: center;
}

.ghost-btn:focus {
  outline: 2px solid #8a8378;
  outline-offset: 2px;
}

.ghost-btn:active {
  opacity: 0.7;
}

.status {
  position: absolute;
  top: 72px;
  top: calc(72px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  left: 0;
  right: 0;
  text-align: center;
  z-index: 2;
}

.status-label {
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--mute);
}

.timer {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 300;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--ink);
}

.print-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  min-width: 0;
}

.print-hit {
  position: relative;
  width: 82vmin;
  height: 82vmin;
  max-width: 92%;
  max-height: 72%;
  border: 0;
  background: transparent;
  touch-action: none;
}

.app:not(.is-session) .print-hit {
  animation: breathe 5.8s ease-in-out infinite;
}

.print-hit.is-holding,
.app.is-holding .print-hit {
  animation: none;
  transform: scale(0.975);
}

.print-hit canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.glow {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 0 0 rgba(244, 241, 234, 0);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.2);
  transition: opacity 180ms ease, transform 180ms ease;
}

.app.is-practice .glow {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 18px 8px rgba(244, 241, 234, 0.42);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

.app.is-holding .glow {
  opacity: 0.9;
}

.hint {
  min-height: 44px;
  padding-left: 32px;
  padding-right: 32px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--hint);
}

.app.is-session .hint {
  opacity: 0;
}

.bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
}

.circle-btn {
  width: 52px;
  height: 52px;
  border: 1px solid #3a3a3c;
  border-radius: 50%;
  background: transparent;
  position: relative;
}

.circle-btn:active {
  opacity: 0.7;
}

.circle-btn:focus {
  outline: 2px solid #cfcac0;
  outline-offset: 3px;
}

.icon-x,
.icon-x::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1px;
  background: #f3f1ec;
}

.icon-x {
  margin-left: -7px;
  margin-top: -0.5px;
  transform: rotate(45deg);
}

.icon-x::after {
  content: "";
  margin-left: 0;
  margin-top: 0;
  transform: rotate(90deg);
}

.icon-check {
  position: absolute;
  left: 19px;
  top: 20px;
  width: 12px;
  height: 7px;
  border-left: 1.5px solid #f3f1ec;
  border-bottom: 1.5px solid #f3f1ec;
  transform: rotate(-45deg);
}

.sheet-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  bottom: calc(6px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  height: 28px;
  border: 0;
  background: transparent;
}

.handle-bar {
  display: block;
  width: 36px;
  height: 3px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 99px;
  background: #c9c1b3;
}

.app.is-dark .handle-bar {
  background: #2f2f32;
}

.app.is-session .sheet-handle {
  opacity: 0;
  pointer-events: none;
}

.overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 20;
  background: rgba(28, 26, 22, 0.28);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.overlay.is-open {
  display: flex;
}

.overlay.is-center {
  align-items: center;
}

.sheet,
.modal {
  width: 100%;
  background: #f7f3ea;
  color: #2f2c28;
}

.sheet {
  padding: 10px 20px 28px;
  padding-bottom: calc(28px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

.modal {
  width: 86%;
  max-width: 360px;
  padding: 28px 22px 20px;
  border-radius: 18px;
}

.sheet-head {
  text-align: center;
}

.sheet-title,
.modal-title {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.sheet-sub,
.modal-copy {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: #8a8378;
}

.snap-row,
.guide-row {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin-top: 18px;
  padding-bottom: 6px;
}

.snap-card,
.guide-card {
  flex: 0 0 auto;
  width: 88px;
  text-align: center;
}

.snap-card + .snap-card,
.guide-card + .guide-card {
  margin-left: 14px;
}

.snap-card canvas,
.guide-card canvas {
  display: block;
  width: 88px;
  height: 88px;
  background: #fffdf8;
  border-radius: 12px;
}

.snap-empty {
  width: 100%;
  padding: 28px 12px;
  text-align: center;
  font-size: 13px;
  color: #8a8378;
}

.guide-label {
  margin-top: 8px;
  font-size: 11px;
  color: #8a8378;
  letter-spacing: 0.04em;
}

.text-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: 0;
  background: transparent;
  color: #6d675d;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.text-btn:active {
  opacity: 0.7;
}

.text-btn:focus {
  outline: 2px solid #8a8378;
  outline-offset: 2px;
}

@media (min-width: 520px) {
  .print-hit {
    width: 420px;
    height: 420px;
    max-width: 70%;
    max-height: 62%;
  }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 16px 7px rgba(244, 241, 234, 0.34); }
  50% { box-shadow: 0 0 24px 11px rgba(244, 241, 234, 0.52); }
}

@media (prefers-reduced-motion: reduce) {
  .app,
  .print-hit,
  .glow {
    transition: none;
    animation: none;
  }
}
