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

:root {
  --bg: #F2ECE4;
  --surface: #FAF6EF;
  --text: #2C241B;
  --text-light: #8B7D6B;
  --brass: #C4956A;
  --brass-dark: #A67B4F;
  --honey: #D4A051;
  --sage: #7B9E89;
  --shadow-sm: 0 1px 3px rgba(44, 36, 27, 0.06);
  --shadow-md: 0 2px 8px rgba(44, 36, 27, 0.08);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body.no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 0;
}

.header {
  text-align: center;
  padding: calc(24px + var(--safe-t)) 0 6px;
}

.logo {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.85rem;
  font-weight: 700;
  font-variation-settings: "SOFT" 80;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 400;
  margin-top: 3px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.board-header {
  text-align: center;
  padding: 8px 0 12px;
  position: relative;
}

.export-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.1rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
  line-height: 1;
}

.export-btn:active {
  background: rgba(44, 36, 27, 0.06);
  color: var(--text);
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(44, 36, 27, 0.07);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brass), var(--honey));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-label {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.bingo-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 4px 0;
}

@media (max-width: 359px) {
  .bingo-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

.bingo-ball {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  border: 1px solid rgba(44, 36, 27, 0.06);
  background: var(--surface);
  color: var(--text);
}

.bingo-ball:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-sm);
}

@media (hover: hover) {
  .bingo-ball:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(196, 149, 106, 0.2);
  }
}

.bingo-ball .ball-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(0.68rem, 3.2vw, 0.82rem);
  font-weight: 600;
  font-variation-settings: "SOFT" 60;
  line-height: 1.2;
  padding: 0 2px;
  word-break: break-word;
  max-width: 90%;
  color: var(--text);
}

.bingo-ball .ball-address {
  font-size: 0.5rem;
  color: var(--text-light);
  line-height: 1.2;
  margin-top: 1px;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bingo-ball .ball-feeling {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 1.6rem;
  line-height: 1;
  z-index: 2;
  filter: drop-shadow(0 1px 3px rgba(44, 36, 27, 0.15));
}

.bingo-ball .ball-count {
  position: absolute;
  bottom: 5px;
  right: 6px;
  background: rgba(44, 36, 27, 0.07);
  color: var(--text-light);
  font-family: "DM Mono", monospace;
  font-size: 0.5rem;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.bingo-ball .ball-photo-thumb {
  position: absolute;
  bottom: 5px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid rgba(44, 36, 27, 0.08);
}

.bingo-ball.ball-picked {
  animation: pulse-glow 0.6s ease 3;
  z-index: 10;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow-sm); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 4px rgba(212, 160, 81, 0), 0 0 24px 6px rgba(212, 160, 81, 0.4); }
}

.bingo-ball.marked {
  border-color: rgba(212, 160, 81, 0.25);
  box-shadow: 0 0 0 1.5px rgba(212, 160, 81, 0.12), var(--shadow-sm);
}

.bingo-ball.marked .ball-name {
  opacity: 0.65;
}

.bingo-ball.marked .ball-count {
  opacity: 0.65;
}

.bingo-ball.marked .ball-photo-thumb {
  opacity: 0.65;
}

.bingo-ball.marked::after {
  content: "✦";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: var(--honey);
  opacity: 0.45;
  text-shadow: 0 0 14px rgba(212, 160, 81, 0.25);
  pointer-events: none;
  line-height: 1;
}

.bingo-ball.nonexistent {
  opacity: 0.5;
  filter: grayscale(0.6);
  border-color: rgba(44, 36, 27, 0.04);
}

.bingo-ball.nonexistent .ball-name {
  text-decoration: line-through;
  opacity: 0.6;
}

.bingo-ball.nonexistent .ball-address {
  opacity: 0.5;
}

.bingo-ball.nonexistent .ball-feeling {
  filter: none;
  opacity: 0.7;
}

.ball-c0 { background: #FDF6EC; }
.ball-c1 { background: #F0E6D3; }
.ball-c2 { background: #EADCC5; }
.ball-c3 { background: #F5E1DA; }
.ball-c4 { background: #E2EED9; }
.ball-c5 { background: #FDE8D8; }
.ball-c6 { background: #E8DEE8; }
.ball-c7 { background: #DCE8E5; }
.ball-c8 { background: #F5E0DD; }
.ball-c9 { background: #F0ECD8; }

.fab-stack {
  position: fixed;
  bottom: calc(24px + var(--safe-b));
  right: calc(24px + var(--safe-r));
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 100;
}

.fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #FAF6EF;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  box-shadow: var(--shadow-md);
}

.fab:active {
  transform: scale(0.88);
}

.fab-add {
  background: var(--brass);
  box-shadow: 0 3px 12px rgba(196, 149, 106, 0.35);
}

.fab-add:active {
  background: var(--brass-dark);
}

.fab-random {
  background: rgba(44, 36, 27, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-size: 1.2rem;
}

.fab-random:active {
  background: rgba(44, 36, 27, 0.75);
}

.fab-sky {
  background: rgba(123, 158, 137, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-size: 1.1rem;
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease, background 0.2s ease;
}

.fab-sky.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.fab-sky:active {
  background: rgba(123, 158, 137, 0.9);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 27, 0.45);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + var(--safe-b));
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(44, 36, 27, 0.1);
  border-radius: 2px;
  margin: 0 auto 14px;
  touch-action: none;
}

.sheet-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  font-variation-settings: "SOFT" 80;
  color: var(--text);
  margin-bottom: 16px;
  padding-right: 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(44, 36, 27, 0.1);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(44, 36, 27, 0.03);
  transition: border-color 0.2s ease, background 0.2s ease;
  font-family: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brass);
  background: rgba(44, 36, 27, 0.05);
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

.field-static {
  padding: 12px 14px;
  background: rgba(44, 36, 27, 0.03);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.field-static-address {
  padding: 0 14px 10px;
  font-size: 0.78rem;
  color: var(--text-light);
  background: rgba(44, 36, 27, 0.03);
  border-radius: 0 0 10px 10px;
  margin-top: -2px;
}

.feelings {
  display: flex;
  gap: 12px;
  padding: 4px 0;
}

.feeling {
  font-size: 2rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  opacity: 0.3;
  transform: scale(0.9);
}

.feeling:active {
  transform: scale(1.1);
}

.feeling.active {
  opacity: 1;
  transform: scale(1.05);
}

.photo-upload {
  position: relative;
}

.photo-upload input[type="file"] {
  display: none;
}

.photo-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px dashed rgba(44, 36, 27, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  touch-action: manipulation;
}

.photo-label:active {
  border-color: var(--brass);
  background: rgba(196, 149, 106, 0.05);
}

.photo-icon {
  font-size: 1.3rem;
}

.photo-text {
  font-size: 0.88rem;
  color: var(--text-light);
}

.photo-preview {
  position: relative;
  display: inline-block;
  margin-top: 10px;
}

.photo-preview img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(44, 36, 27, 0.55);
  color: #FAF6EF;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.photo-remove:active {
  background: rgba(44, 36, 27, 0.75);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--brass);
  color: #FAF6EF;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  touch-action: manipulation;
  min-height: 48px;
}

.btn-primary:active {
  background: var(--brass-dark);
  transform: scale(0.98);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 27, 0.6);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 24px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 24px 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(44, 36, 27, 0.12);
  position: relative;
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  margin: auto;
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.3rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  touch-action: manipulation;
}

.modal-close:active {
  background: rgba(44, 36, 27, 0.06);
}

.modal-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  font-variation-settings: "SOFT" 80;
  margin-bottom: 2px;
  color: var(--text);
}

.modal-address {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.modal-visit-count {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.modal-feeling {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.modal-date,
.modal-with {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 5px;
}

.modal-photo {
  margin: 10px 0 12px;
}

.modal-photo img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
}

.modal-notes {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  margin: 12px 0 18px;
  padding: 12px 14px;
  background: rgba(44, 36, 27, 0.03);
  border-radius: 8px;
}

.modal-delete {
  width: 100%;
  padding: 12px;
  background: rgba(44, 36, 27, 0.05);
  color: var(--text-light);
  border: 1px solid rgba(44, 36, 27, 0.08);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
}

.modal-delete:active {
  background: rgba(44, 36, 27, 0.08);
  color: var(--text);
}

.sheet-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 18px;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
