:root {
  --bg-color: #0a0a0a;
  --text-color: #e0e0e0;
  --accent-color: #ff0055; /* Neon Red */
  --highlight-color: #00ffcc; /* Cyan */
  --receipt-bg: #f0f0f0;
  --receipt-text: #1a1a1a;
  --font-main: 'Noto Sans KR', sans-serif;
  --font-mono: 'Courier Prime', monospace;
  --good-color: #00cc66; /* Green */
  --book-bg: #1e1e1e;
  --book-page-bg: #fff;
  --book-spine: #333;
  --guide-cover-color: #2e7d32; /* Green for Guide */
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-main);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
  transition: background-color 0.5s ease;
}

/* Effect Layers */
#effects-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
  overflow: hidden;
}

/* CRT Scanline Effect */
.scan-line {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.2) 50%,
    rgba(0, 0, 0, 0.2)
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 999;
}

/* Marquee Effect */
.marquee-wrapper {
  position: fixed;
  top: 15px;
  left: 0;
  width: 100%;
  overflow: hidden;
  z-index: 5;
  pointer-events: none;
  opacity: 0.5;
  filter: blur(0.8px);
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.marquee-content {
  display: flex;
  white-space: nowrap;
  animation: scroll-left 25s linear infinite;
}

.marquee-content span {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--highlight-color);
  padding-right: 20px;
}

.marquee-content .divider {
  color: var(--accent-color);
  font-weight: bold;
}

@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.container {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  z-index: 10;
}

/* Header & Glitch Text */
header {
  text-align: center;
  margin-bottom: 20px;
}

.main-copy {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.3;
  text-transform: uppercase;
  position: relative;
  margin-bottom: 15px;
}

.highlight-trash {
  color: var(--accent-color);
  text-decoration: underline;
  text-underline-offset: 5px;
}

.sub-copy {
  font-size: 0.9rem;
  color: #888;
  line-height: 1.5;
}

.warning {
  color: var(--accent-color);
  font-weight: 700;
  display: block;
  margin-top: 5px;
}

/* Glitch Animation Keyframes */
@keyframes glitch-anim {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

.glitch:hover {
  animation: glitch-anim 0.3s infinite;
  color: var(--highlight-color);
}

/* Form Styles */
.input-zone {
  background: #111;
  padding: 20px;
  border: 1px solid #333;
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: all 0.3s ease;
}

.input-group {
  margin-bottom: 15px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 5px;
  font-family: var(--font-mono);
}

input {
  width: 100%;
  padding: 12px;
  background: #000;
  border: 1px solid #444;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--highlight-color);
}

.submit-btn {
  width: 100%;
  padding: 15px;
  background: var(--accent-color);
  color: white;
  border: none;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s;
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:hover {
  background: #ff3377;
  box-shadow: 0 0 15px var(--accent-color);
}

/* ================== 3D BOOK UI ================== */
.result-zone.hidden { display: none; }

.book-wrapper {
  perspective: 1500px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 450px; /* Adjust based on content */
  margin-bottom: 30px;
}

.book {
  width: 500px; /* Total width (250px per page) */
  height: 380px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.book.open {
  transform: translateX(125px) rotateY(0deg); /* Shift right to center open book */
}

/* Pages */
.book-cover, .book-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 250px;
  height: 100%;
  backface-visibility: hidden;
  transform-origin: left center;
  transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* Front Cover */
.book-cover {
  background: #111;
  color: var(--highlight-color);
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 2px solid #333;
  transform: rotateY(0deg);
  border-radius: 4px 0 0 4px;
}

.cover-content h2 {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  border: 4px solid var(--highlight-color);
  padding: 10px;
  margin-bottom: 20px;
}

.book.open .book-cover {
  transform: rotateY(-180deg);
  z-index: 0;
}

/* Left Page (Receipt) */
.book-page.left {
  background: #fdfdfd;
  z-index: 5;
  transform: rotateY(0deg); /* Initially hidden under cover */
  border-right: 1px solid #ddd;
}

.book.open .book-page.left {
  /* It stays flat but becomes visible when cover flips */
  z-index: 1;
}

/* Right Page (Prescription) */
.book-page.right {
  background: #fff;
  z-index: 1;
  left: 250px; /* Positioned to the right */
  transform: rotateY(0deg);
  transform-origin: left center;
  border-left: 1px solid #eee;
}

/* Page Content Styling */
.page-content {
  padding: 15px;
  height: 100%;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #000;
  display: flex;
  flex-direction: column;
}

/* Mini Receipt in Book */
.receipt {
  background: var(--receipt-bg);
  color: #000;
  padding: 10px;
  font-size: 0.7rem;
  border: 1px dashed #ccc;
  width: 100%;
}
.receipt-header { text-align: center; margin-bottom: 10px; }
.line-item { display: flex; justify-content: space-between; font-weight: bold; }
.reason-row { font-style: italic; color: #555; margin-bottom: 5px; }
.total-row { display: flex; justify-content: space-between; font-weight: 900; margin-top: 5px; border-top: 1px dashed #000; padding-top: 5px; }
.ai-analysis { margin-top: 10px; background: #eee; padding: 5px; border-left: 3px solid #000; }
.roast-text { font-size: 0.7rem; line-height: 1.3; }
.footer-msg { text-align: center; font-size: 0.6rem; margin-top: 10px; font-weight: bold; }

/* Guide Link in Receipt */
.guide-link-container {
  margin-top: 10px;
  text-align: center;
  border-top: 1px dotted #999;
  padding-top: 5px;
}
#guide-link {
  font-size: 0.65rem;
  color: #0066cc;
  text-decoration: none;
  font-weight: bold;
}
#guide-link:hover { text-decoration: underline; }

/* Mini Prescription in Book (Updated to Report Format) */
.prescription-card {
  border: 2px solid #333;
  padding: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  font-family: var(--font-mono);
}

.report-header {
  border-bottom: 2px solid #333;
  margin-bottom: 10px;
  padding-bottom: 5px;
  text-align: center;
}

.report-header h3 {
  font-size: 0.9rem;
  font-weight: 900;
  margin-bottom: 2px;
}

.report-date {
  font-size: 0.6rem;
  color: #666;
}

.report-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.report-section h4 {
  font-size: 0.7rem;
  font-weight: bold;
  background: #eee;
  padding: 2px 5px;
  margin-bottom: 3px;
  border-left: 3px solid var(--accent-color);
}

.report-section p {
  font-size: 0.65rem;
  line-height: 1.3;
  padding-left: 5px;
  white-space: pre-wrap; /* Allow newlines */
}

.commandments-list {
  padding-left: 15px;
  margin: 0;
}

.commandments-list li {
  font-size: 0.65rem;
  margin-bottom: 2px;
  line-height: 1.3;
}

.final-grade-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed #ccc;
  padding-top: 5px;
  margin-top: auto;
}

.grade-stamp {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent-color);
  border: 3px solid var(--accent-color);
  padding: 2px 10px;
  border-radius: 5px;
  transform: rotate(-10deg);
  opacity: 0.8;
  mask-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/8399/grunge.png');
  mask-size: 200px 100px;
}

.report-footer {
  margin-top: 10px;
  text-align: center;
  font-size: 0.55rem;
  color: var(--accent-color);
  font-weight: bold;
  border-top: 1px solid #333;
  padding-top: 5px;
}

/* Download Link (Text based) */
.download-link-container {
  text-align: center;
  margin-bottom: 15px;
}

#download-link {
  font-family: var(--font-mono);
  font-size: 1.1rem; /* Larger */
  font-weight: 900; /* Boldest */
  color: #fff; /* Bright white */
  text-decoration: none;
  border-bottom: 2px solid var(--highlight-color); /* Thicker underline */
  padding-bottom: 5px;
  transition: all 0.2s;
  cursor: pointer;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#download-link:hover {
  color: var(--highlight-color);
  border-bottom-color: #fff;
  text-shadow: 0 0 10px var(--highlight-color);
}

/* Nav Controls (Home Button) */
.nav-controls {
  text-align: center;
  margin-top: 20px;
}
.secondary-btn {
  padding: 12px 35px;
  background: transparent;
  color: var(--text-color);
  border: 2px solid var(--text-color); /* Thicker border */
  font-family: var(--font-mono);
  font-size: 1rem; /* Larger */
  font-weight: 900; /* Boldest */
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.secondary-btn:hover { background: var(--text-color); color: var(--bg-color); }


/* ================== GUIDE BOOK OVERLAY (Anime Style) ================== */
.guide-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); /* Slightly darker backdrop */
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.guide-overlay.hidden { display: none; }

.guide-book-wrapper {
  perspective: 1800px; /* Enhanced perspective */
}

.guide-book {
  width: 800px; /* Larger book width */
  height: 600px; /* Larger book height */
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.guide-book.open {
  transform: translateX(200px); /* Center the open book (half of page width) */
}

.guide-page {
  position: absolute;
  top: 0; left: 0;
  width: 400px; /* Wider pages */
  height: 100%;
  backface-visibility: hidden;
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 5px 25px rgba(0,0,0,0.6);
  background: #fff;
  color: #000;
  padding: 30px; /* More padding */
  overflow-y: auto; /* Allow scrolling if content overflows */
}

/* Guide Cover */
.guide-cover {
  background: var(--guide-cover-color);
  color: #fff;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 5px 0 0 5px;
  border: 3px solid #1b5e20;
}
.guide-cover-content { text-align: center; }
.guide-cover-content h2 { font-size: 2.5rem; border: 4px solid #fff; padding: 15px; margin-bottom: 15px; }
.guide-cover-content .icon { font-size: 4rem; display: block; margin-top: 20px; }

.guide-book.open .guide-cover {
  transform: rotateY(-180deg);
  z-index: 0;
}

/* Guide Pages */
.guide-left {
  z-index: 15;
  transform: rotateY(0deg);
  background: #f9fbe7; /* Very Light Green */
  border-right: 1px solid #ccc;
}
.guide-book.open .guide-left { z-index: 1; }

.guide-right {
  left: 400px;
  z-index: 1;
  background: #fff;
  border-left: 1px solid #ccc;
}

/* Guide Text Styling */
.guide-content h3 {
  font-size: 1.2rem;
  border-bottom: 3px solid var(--guide-cover-color);
  padding-bottom: 10px;
  margin-bottom: 20px;
  color: var(--guide-cover-color);
  font-weight: 900;
}

.guide-text h4 {
  font-size: 1rem;
  margin-top: 20px;
  margin-bottom: 10px;
  color: #333;
  background: rgba(0,0,0,0.05);
  padding: 5px 10px;
  border-left: 4px solid var(--guide-cover-color);
}

.guide-text p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 10px;
  color: #444;
}

.guide-text ul {
  padding-left: 20px;
  margin-bottom: 15px;
}

.guide-text li {
  font-size: 0.85rem;
  margin-bottom: 5px;
  line-height: 1.4;
}

.template-box {
  background: #333;
  color: #eee;
  padding: 15px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin: 15px 0;
}

.template-box p {
  color: #eee;
  margin-bottom: 5px;
}

.warning-text {
  color: #d32f2f !important;
  font-weight: bold;
  text-align: center;
  margin-top: 20px;
  border: 1px solid #d32f2f;
  padding: 10px;
}

.close-guide-btn {
  margin-top: 30px;
  padding: 12px 30px;
  background: #fff;
  color: #333;
  border: none;
  font-weight: 900;
  cursor: pointer;
  border-radius: 30px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}
.close-guide-btn:hover { background: #eee; transform: scale(1.05); }

/* Mobile Responsiveness for Large Book */
@media (max-width: 850px) {
  .guide-book-wrapper { perspective: none; width: 90%; }
  .guide-book {
    width: 100%; height: auto; transform: none !important;
    display: flex; flex-direction: column; gap: 20px;
  }
  .guide-page, .guide-cover, .guide-left, .guide-right {
    position: relative; width: 100%; height: auto; left: 0; top: 0;
    transform: none !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  }
  .guide-cover { display: none; } /* Hide cover on mobile */
  .guide-book.open { transform: none; }
}


/* ------------------- VISUAL EFFECTS ------------------- */
body.mode-bad { animation: siren-flash 0.5s infinite; }
@keyframes siren-flash { 0%, 100% { background-color: #2a0000; } 50% { background-color: #500000; } }

.bad-marquee {
  position: fixed; top: 50%; left: 0; width: 100%; background: red; color: white;
  padding: 15px 0; font-weight: 900; font-size: 1.5rem;
  transform: translateY(-50%) rotate(-5deg); z-index: 950;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); white-space: nowrap; overflow: hidden; display: flex;
}
.bad-marquee-track { display: flex; white-space: nowrap; animation: scroll-bad 20s linear infinite; will-change: transform; }
.bad-marquee-track span { padding-right: 20px; }
@keyframes scroll-bad { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

.stamp {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-15deg) scale(2);
  border: 5px solid; font-size: 2rem; font-weight: 900; padding: 10px 20px;
  text-transform: uppercase; letter-spacing: 2px; opacity: 0; z-index: 1000;
  border-radius: 10px; mask-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/8399/grunge.png');
  mask-size: 940px 600px; mix-blend-mode: multiply;
  animation: stamp-land 0.3s cubic-bezier(0.6, 0.04, 0.98, 0.335) forwards; animation-delay: 1.2s;
  text-align: center; line-height: 1.2;
}
.stamp.bad { border-color: #d00; color: #d00; }
.stamp.good { border-color: var(--good-color); color: var(--good-color); font-size: 1.5rem; transform: translate(-50%, -50%) rotate(-5deg) scale(2); }
@keyframes stamp-land {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-15deg) scale(2); }
  100% { opacity: 0.8; transform: translate(-50%, -50%) rotate(-15deg) scale(1); }
}

body.mode-good { background-color: #fcf8e3; color: #333; }
body.mode-good .scan-line { display: none; }
body.mode-good header .main-copy { color: #d4af37; text-shadow: 0 0 10px rgba(212, 175, 55, 0.5); }
body.mode-good .input-zone { background: #fff; border-color: #d4af37; box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3); }
body.mode-good input { background: #fdfdfd; color: #333; border-color: #ddd; }

/* Coin Shower Effect */
.coin {
  position: absolute; top: -100px; width: 35px; height: 35px;
  background-image: url('/coin.png'); background-size: 280%; background-position: center;
  border-radius: 50%; border: 2px solid #d4af37; box-shadow: 0 4px 10px rgba(212, 175, 55, 0.5);
  z-index: 910;
  --fall-duration: 3s; --fall-delay: 0s; --coin-scale: 1; --sway-dir: 1;
  transform: scale(var(--coin-scale)); opacity: 1; will-change: transform;
  animation: coin-shower var(--fall-duration) linear forwards; animation-delay: var(--fall-delay);
}
@keyframes coin-shower {
  0% { transform: translateY(0) translateX(0) rotateX(0deg) rotateZ(0deg) scale(var(--coin-scale)); }
  25% { transform: translateY(25vh) translateX(calc(20px * var(--sway-dir))) rotateX(120deg) rotateZ(45deg) scale(var(--coin-scale)); }
  50% { transform: translateY(50vh) translateX(0) rotateX(240deg) rotateZ(90deg) scale(var(--coin-scale)); }
  75% { transform: translateY(75vh) translateX(calc(20px * var(--sway-dir) * -1)) rotateX(360deg) rotateZ(135deg) scale(var(--coin-scale)); }
  100% { transform: translateY(110vh) translateX(0) rotateX(720deg) rotateZ(180deg) scale(var(--coin-scale)); }
}

.flying-emoji {
  position: absolute; font-size: 2rem; animation: fly-away 3s linear forwards;
}
@keyframes fly-away { to { transform: translateY(-100vh) translateX(50px) rotate(360deg); opacity: 0; } }

/* Footer Buttons & Share */
.footer-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.share-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out;
  opacity: 0;
  margin-bottom: 15px;
}

.share-container.open {
  max-height: 100px;
  opacity: 1;
}

/* Footer & Contact Inline */
.main-footer {
  margin-top: 50px;
  text-align: center;
  padding-bottom: 20px;
  border-top: 1px solid #333;
  padding-top: 20px;
}

.main-footer p {
  color: #666;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.footer-link {
  background: none;
  border: 1px solid #444;
  color: #888;
  padding: 8px 15px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  margin-bottom: 15px;
}

.footer-link:hover {
  border-color: var(--highlight-color);
  color: var(--highlight-color);
}

/* Inline Contact Form Styles */
.contact-inline {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  overflow: hidden;
  max-height: 0; /* For slide effect */
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
  opacity: 0;
}

.contact-inline.open {
  max-height: 500px; /* Approximate height to fit form */
  opacity: 1;
}

.contact-content-inline {
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 20px;
  margin-top: 10px;
  text-align: center;
}

.contact-content-inline h3 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: var(--highlight-color);
}

.contact-content-inline p {
  font-size: 0.8rem;
  margin-bottom: 15px;
}

.contact-form textarea {
  min-height: 80px;
}

/* Ensure hidden utility works if needed */
.hidden { display: none !important; }