/* ==========================================================================
   《這網頁漏水了》 The Leaking Website — v2.0 Director's Cut
   Museum-Grade Editorial Minimalism × Tactile Fluid Chaos
   ========================================================================== */

:root {
  --bg-paper: #F6F3EC;
  --bg-card: #FFFEFB;
  --bg-subtle: #EFECE4;
  --ink-primary: #1C1B19;
  --ink-secondary: #56524B;
  --ink-muted: #8B857B;
  --border-hairline: #E2DDD2;
  --accent-zen: #35584B;
  --accent-seal: #B84435;
  --water-bright: #00A6ED;
  --water-deep: #0B4F8A;
  --tape-yellow: #F7D44C;
  --tape-red: #E85D4A;
  --tape-blue: #2589BD;
  --font-serif: "Songti TC", "Noto Serif TC", "PMingLiU", Georgia, serif;
  --font-sans: "PingFang TC", "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --para-font-scale: 1;
}

body.theme-dark {
  --bg-paper: #16181C;
  --bg-card: #202329;
  --bg-subtle: #282C34;
  --ink-primary: #EFECE6;
  --ink-secondary: #B4B0A8;
  --ink-muted: #7C8088;
  --border-hairline: #32363F;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-paper);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 1.4s ease, color 0.6s ease;
}

body.phase-submerged {
  background-color: #06253E !important;
}

body.holding-tape,
body.holding-tape * {
  cursor: none !important;
}

body.screen-shake {
  animation: screenShake 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-5px, 3px, 0); }
  45% { transform: translate3d(5px, -3px, 0); }
  70% { transform: translate3d(-3px, 2px, 0); }
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Fine-Art Paper Grain & Screen Flash
   ========================================================================== */
.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 590;
  opacity: 0.04;
  background-image: radial-gradient(rgba(28, 27, 25, 0.55) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 750;
  opacity: 0;
  background: #FFFFFF;
  transition: opacity 0.25s ease;
}

.screen-flash.flash-crack {
  background: rgba(144, 224, 239, 0.45);
  opacity: 1;
}

.screen-flash.flash-rewind {
  background: rgba(247, 212, 76, 0.45);
  opacity: 1;
}

.screen-flash.flash-steam {
  background: rgba(255, 245, 225, 0.42);
  opacity: 1;
}

/* ==========================================================================
   Top Progress / Flood Bar
   ========================================================================== */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(28, 27, 25, 0.08);
  z-index: 600;
  transition: height 0.4s ease;
}

body.phase-flood .top-progress-bar { height: 4px; }

.top-progress-fill {
  height: 100%;
  width: 12%;
  background: var(--ink-primary);
  transition: width 0.22s linear, background-color 0.5s ease;
}

body.phase-flood .top-progress-fill {
  background: linear-gradient(90deg, #00B4D8, #0077B6);
}

body.phase-submerged .top-progress-fill {
  background: linear-gradient(90deg, #6FFFE9, #00B4D8);
}

/* ==========================================================================
   Underwater God Rays & Caustic Atmosphere
   ========================================================================== */
.underwater-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 380;
  opacity: 0;
  transition: opacity 2.2s ease;
  overflow: hidden;
}

body.phase-submerged .underwater-atmosphere { opacity: 1; }

.god-ray {
  position: absolute;
  top: -18%;
  width: 22vw;
  height: 140vh;
  background: linear-gradient(180deg, rgba(168, 245, 255, 0.24) 0%, rgba(72, 202, 228, 0.06) 58%, rgba(0, 0, 0, 0) 100%);
  transform-origin: top center;
  filter: blur(20px);
  animation: raySway 9s ease-in-out infinite alternate;
}

.ray-1 { left: 6%; transform: rotate(15deg); animation-delay: 0s; }
.ray-2 { left: 32%; width: 28vw; transform: rotate(9deg); animation-delay: -2.8s; }
.ray-3 { left: 60%; width: 19vw; transform: rotate(18deg); animation-delay: -5.2s; }
.ray-4 { left: 82%; width: 16vw; transform: rotate(12deg); animation-delay: -1.4s; }

@keyframes raySway {
  0% { transform: rotate(10deg) translateX(-20px); opacity: 0.5; }
  100% { transform: rotate(19deg) translateX(24px); opacity: 0.95; }
}

.caustics-shimmer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 18%, rgba(114, 239, 221, 0.14), transparent 52%),
    radial-gradient(circle at 76% 58%, rgba(0, 180, 216, 0.16), transparent 48%),
    linear-gradient(180deg, rgba(0, 180, 216, 0.08), rgba(2, 20, 38, 0.35));
  mix-blend-mode: screen;
}

/* ==========================================================================
   Fluid Canvases
   ========================================================================== */
.fluid-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fluid-canvas-back { z-index: 15; }
.fluid-canvas-front { z-index: 350; }

/* ==========================================================================
   Editorial Site Header
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 26px;
  height: 56px;
  background: rgba(246, 243, 236, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-hairline);
  z-index: 450;
  transition: background-color 0.8s ease, border-color 0.8s ease, color 0.8s ease;
}

body.theme-dark .site-header {
  background: rgba(22, 24, 28, 0.88);
}

body.phase-submerged .site-header {
  background: rgba(6, 37, 62, 0.68) !important;
  border-bottom-color: rgba(144, 224, 239, 0.22);
  color: #D9F2F7;
}

.header-inner {
  max-width: 1240px;
  height: 100%;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.2px solid currentColor;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.brand-issue {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
}

body.phase-submerged .brand-issue { color: rgba(202, 240, 248, 0.65); }

.telemetry-strip {
  display: flex;
  align-items: center;
}

.telemetry-item {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.flood-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(0, 166, 237, 0.28);
  padding: 4px 13px;
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(11, 79, 138, 0.09);
}

body.phase-submerged .flood-hud {
  background: rgba(8, 48, 80, 0.78);
  border-color: rgba(144, 224, 239, 0.3);
}

.hud-divider {
  width: 1px;
  height: 14px;
  background: var(--border-hairline);
}

.hud-metric {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.hud-label {
  font-size: 10.5px;
  color: var(--ink-muted);
}

body.phase-submerged .hud-label { color: rgba(186, 232, 244, 0.78); }

.hud-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-primary);
}

body.phase-submerged .hud-value { color: #E0FBFC; }
.hud-value.danger { color: #E03E2D; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.font-size-group {
  display: inline-flex;
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
}

.seg-btn {
  padding: 5px 8px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-serif);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg-btn + .seg-btn {
  border-left: 1px solid var(--border-hairline);
}

.seg-btn:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--ink-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.icon-btn:hover {
  color: var(--ink-primary);
  border-color: var(--ink-muted);
  transform: translateY(-1px);
}

.icon-btn em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #0077B6;
}

body.phase-submerged .icon-btn,
body.phase-submerged .font-size-group {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #E0FBFC;
}

body.phase-submerged .seg-btn { color: #E0FBFC; }

.bug-report-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bug-report-btn:hover {
  border-color: var(--ink-primary);
  color: var(--ink-primary);
}

.bug-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #B8B2A6;
}

body.phase-flood .bug-report-btn {
  background: #FFF3BF;
  border-color: #E5B82E;
  color: #4D3700;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(229, 184, 46, 0.28);
}

body.phase-flood .bug-report-btn:hover {
  background: #FFE885;
  transform: translateY(-1px);
}

body.phase-flood .bug-dot {
  background: #E85D4A;
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.6; }
}

.tape-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: #E85D4A;
  color: #FFF;
  padding: 1px 6px;
  border-radius: 999px;
}

/* ==========================================================================
   Main Editorial Stage & Ghost Outlines
   ========================================================================== */
.editorial-stage {
  position: relative;
  width: calc(100% - 26px);
  height: 100vh;
  padding-top: 66px;
  overflow: hidden;
  z-index: 40;
}

.ghost-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
}

.editorial-ghost {
  position: fixed;
  border: 1px dashed var(--border-hairline);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  opacity: 0.55;
  background: rgba(0, 0, 0, 0.015);
}

body.phase-submerged .editorial-ghost {
  border-color: rgba(144, 224, 239, 0.18);
  color: rgba(186, 232, 244, 0.45);
}

.article-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 6px 26px 20px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.meta-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-zen);
  letter-spacing: 0.14em;
}

body.theme-dark .meta-kicker { color: #6FC3A5; }
body.phase-submerged .article-meta { color: rgba(186, 232, 244, 0.72); }
body.phase-submerged .meta-kicker { color: #6FFFE9; }

.article-title {
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.1vw, 37px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.22;
  color: var(--ink-primary);
  margin-bottom: 6px;
  transition: color 1.6s ease, text-shadow 1.6s ease;
}

body.phase-submerged .article-title {
  color: #E0FBFC;
  text-shadow: 0 4px 28px rgba(72, 202, 228, 0.65);
}

.article-subtitle {
  font-family: var(--font-serif);
  font-size: 14.5px;
  color: var(--ink-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
  transition: color 1.6s ease;
}

body.phase-submerged .article-subtitle { color: rgba(202, 240, 248, 0.88); }

/* ==========================================================================
   Buoyant Floating Tags & Buttons
   ========================================================================== */
.buoyant-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
  min-height: 40px;
}

body.phase-submerged .buoyant-toolbar {
  border-bottom-color: rgba(144, 224, 239, 0.2);
}

.phys-float {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}

.tag-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--ink-secondary);
}

.action-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  color: var(--ink-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.action-pill:hover { border-color: var(--ink-primary); }

.primary-pill {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: var(--bg-paper);
}

.phys-float.is-floating {
  position: fixed !important;
  z-index: 260;
  box-shadow: 0 6px 16px rgba(11, 79, 138, 0.2);
}

.phys-float.used-sponge {
  opacity: 0.6;
  background: #D9EDF7;
  border-color: #7CC4E8;
  color: #0B4F8A;
}

/* ==========================================================================
   Editorial Grid: Paragraphs, Zen Breathing Widget & Heavy Art Prints
   ========================================================================== */
.editorial-grid {
  display: grid;
  grid-template-columns: 1.48fr 1fr;
  gap: 18px;
  align-items: start;
}

.editorial-col-main,
.editorial-col-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Zen Breathing Widget */
.zen-breathe-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.zen-breathe-card:hover {
  border-color: #00A6ED;
  transform: translateY(-1px);
}

.breathe-orb-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.breathe-orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7CC6A6, #35584B);
  animation: zenBreathe 6s ease-in-out infinite;
}

body.phase-flood .breathe-orb {
  background: radial-gradient(circle at 35% 35%, #72EFDD, #0077B6);
  animation: panicBreathe 1.4s ease-in-out infinite;
}

.breathe-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(53, 88, 75, 0.25);
  border-radius: 50%;
}

@keyframes zenBreathe {
  0%, 100% { transform: scale(0.75); opacity: 0.7; }
  50% { transform: scale(1.4); opacity: 1; }
}

@keyframes panicBreathe {
  0%, 100% { transform: scale(0.8); }
  50% { transform: scale(1.45); }
}

.breathe-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.breathe-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  letter-spacing: 0.06em;
}

.breathe-status {
  font-family: var(--font-serif);
  font-size: 12.5px;
  color: var(--ink-primary);
}

/* Draggable Paragraph Dam Blocks */
.para-card {
  position: relative;
  display: flex;
  gap: 13px;
  padding: 12px 15px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(28, 27, 25, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.25s ease, background-color 0.4s ease;
  will-change: transform;
}

.para-card.is-clone {
  border-style: dashed;
  border-color: #2589BD;
  background: rgba(236, 248, 255, 0.94);
}

body.theme-dark .para-card.is-clone {
  background: rgba(25, 52, 74, 0.94);
}

body.phase-flood .para-card,
body.phase-submerged .para-card {
  cursor: grab;
}

body.phase-flood .para-card:hover {
  border-color: #55A8E0;
  box-shadow: 0 8px 22px rgba(11, 79, 138, 0.14);
}

.para-card.is-physics {
  position: fixed !important;
  z-index: 220;
  margin: 0 !important;
}

.para-card.is-dragging {
  cursor: grabbing !important;
  z-index: 315 !important;
  border-color: #00A6ED !important;
  box-shadow: 0 16px 36px rgba(11, 79, 138, 0.28) !important;
}

.para-card.is-wet {
  background: #ECF7FD;
  border-color: #93CBEB;
}

body.theme-dark .para-card.is-wet {
  background: #1B3142;
  border-color: #3979A1;
}

.para-card.is-soggy {
  background: #D2E9F7;
  border-color: #4D9FD6;
}

body.theme-dark .para-card.is-soggy {
  background: #163C59;
  border-color: #00A6ED;
}

.para-card.is-squashed {
  border-color: #D96B43;
  background: #FFF4EC;
}

body.theme-dark .para-card.is-squashed {
  background: #3A231B;
  border-color: #E87D58;
}

.block-controls {
  position: absolute;
  top: -12px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: #1C1B19;
  color: #F6F3EC;
  padding: 2px 6px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 5;
}

body.phase-flood .para-card:hover .block-controls,
body.phase-submerged .para-card:hover .block-controls,
.para-card.is-dragging .block-controls {
  opacity: 0.94;
  pointer-events: auto;
}

.drag-grip-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding-right: 4px;
}

.rot-btn {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #FFF;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rot-btn:hover { background: #00A6ED; }

.para-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  padding-top: 2px;
  flex-shrink: 0;
}

.para-body h3 {
  font-family: var(--font-serif);
  font-size: calc(14.5px * var(--para-font-scale));
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--ink-primary);
}

.para-body p {
  font-size: calc(12.5px * var(--para-font-scale));
  line-height: 1.54;
  color: var(--ink-secondary);
}

.drop-cap::first-letter {
  font-family: var(--font-serif);
  font-size: 1.35em;
  font-weight: 700;
  color: var(--accent-seal);
}

.quote-card {
  background: var(--bg-subtle);
  border-left: 3px solid var(--ink-primary);
}

.quote-card blockquote {
  font-family: var(--font-serif);
  font-size: calc(13.5px * var(--para-font-scale));
  font-style: italic;
  color: var(--ink-primary);
  margin-bottom: 3px;
}

.quote-card cite {
  font-size: 11px;
  color: var(--ink-muted);
  font-style: normal;
}

.soggy-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
  overflow: hidden;
  border-radius: 0 0 6px 6px;
}

.soggy-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38BDF8, #0284C7);
  transition: width 0.2s linear;
}

/* Heavy Sinking Figures */
.heavy-figure {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 7px;
  box-shadow: 0 3px 10px rgba(28, 27, 25, 0.07);
  will-change: transform;
}

body.phase-flood .heavy-figure,
body.phase-submerged .heavy-figure { cursor: grab; }

.heavy-figure.is-physics {
  position: fixed !important;
  z-index: 245;
  margin: 0 !important;
}

.heavy-figure.is-dragging {
  cursor: grabbing !important;
  z-index: 320 !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.heavy-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: rgba(28, 27, 25, 0.85);
  color: #F6F3EC;
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 2;
}

.heavy-badge-warn { background: rgba(184, 68, 53, 0.92); }

.artwork-frame {
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: #ECE7DC;
}

.editorial-svg {
  display: block;
  width: 100%;
  height: auto;
}

.heavy-figure figcaption {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-muted);
}

/* ==========================================================================
   Dynamic Objects: Draggable Sponge & Live Reader Comment Sandbags
   ========================================================================== */
.dynamic-objects-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 270;
}

.phys-sponge {
  position: fixed;
  width: 114px;
  height: 70px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 22% 32%, rgba(196, 140, 12, 0.45) 4px, transparent 5px),
    radial-gradient(circle at 65% 24%, rgba(196, 140, 12, 0.4) 5px, transparent 6px),
    radial-gradient(circle at 46% 68%, rgba(196, 140, 12, 0.45) 6px, transparent 7px),
    radial-gradient(circle at 82% 62%, rgba(196, 140, 12, 0.38) 4px, transparent 5px),
    linear-gradient(180deg, #FFE46B 0%, #F5C22B 100%);
  border: 2px solid #D99B16;
  box-shadow: 0 8px 22px rgba(217, 155, 22, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: grab;
  z-index: 295;
}

.phys-sponge.sponge-full {
  background:
    radial-gradient(circle at 22% 32%, rgba(11, 79, 138, 0.35) 4px, transparent 5px),
    radial-gradient(circle at 65% 24%, rgba(11, 79, 138, 0.3) 5px, transparent 6px),
    linear-gradient(180deg, #9AD4EC 0%, #58B0DC 100%);
  border-color: #1F78B4;
}

.sponge-title {
  font-size: 11px;
  font-weight: 700;
  color: #4F3600;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.phys-sponge.sponge-full .sponge-title { color: #052D4F; }

.sponge-meter {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: #1C1B19;
  padding: 1px 6px;
  border-radius: 999px;
  margin-top: 3px;
}

/* Live Reader Comment Sandbags */
.comment-card {
  position: fixed;
  width: 224px;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-left: 3px solid #00A6ED;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(11, 79, 138, 0.14);
  pointer-events: auto;
  cursor: grab;
  z-index: 255;
}

.comment-author {
  font-size: 10.5px;
  font-weight: 700;
  color: #0077B6;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
}

.comment-text {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-secondary);
}

/* ==========================================================================
   Cracks & 4-Type Bug Report Tape Stickers
   ========================================================================== */
.crack-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 290;
}

.crack-node {
  position: absolute;
  width: 98px;
  height: 98px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: crosshair;
}

.crack-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 6px rgba(0, 166, 237, 0.55));
}

.crack-pressure-ring {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(0, 166, 237, 0.65);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

body.holding-tape .crack-pressure-ring {
  opacity: 1;
  animation: spinRing 3.6s linear infinite;
}

@keyframes spinRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.crack-label {
  position: absolute;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(11, 79, 138, 0.9);
  color: #FFF;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.tape-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 335;
}

.tape-sticker {
  position: absolute;
  min-width: 96px;
  padding: 6px 12px;
  background: var(--tape-yellow);
  color: #2B2100;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
  border: 1px dashed rgba(43, 33, 0, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform-origin: center;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.tape-sticker.tape-red {
  background: var(--tape-red);
  color: #FFF8F5;
  border-color: rgba(255, 255, 255, 0.45);
}

.tape-sticker.tape-blue {
  background: var(--tape-blue);
  color: #F0FAFF;
  border-color: rgba(255, 255, 255, 0.45);
}

.tape-sticker.tape-white {
  background: #FFFDF7;
  color: #1C1B19;
  border-color: #9B958B;
}

.tape-sticker.peeling {
  animation: tapeBulge 0.42s ease-in-out infinite alternate;
}

@keyframes tapeBulge {
  from { filter: brightness(1); }
  to { filter: brightness(1.1) drop-shadow(0 0 8px rgba(0, 166, 237, 0.75)); }
}

.tape-cursor {
  position: fixed;
  z-index: 900;
  pointer-events: none;
  padding: 6px 14px;
  background: var(--tape-yellow);
  color: #2B2100;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  border: 1px dashed rgba(43, 33, 0, 0.4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
  transform: translate(-50%, -50%) rotate(-7deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tape-cursor.tape-red { background: var(--tape-red); color: #FFF; }
.tape-cursor.tape-blue { background: var(--tape-blue); color: #FFF; }
.tape-cursor.tape-white { background: #FFFDF7; color: #1C1B19; }

.tape-cursor-sub {
  font-size: 9px;
  font-weight: 400;
  opacity: 0.82;
}

/* ==========================================================================
   Emergency Floating Action Bar (Ctrl+Z & Surrender)
   ========================================================================== */
.emergency-bar {
  position: fixed;
  bottom: 18px;
  left: 20px;
  display: flex;
  gap: 8px;
  z-index: 440;
}

.emerg-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.emerg-btn:hover { transform: translateY(-2px); }

.emerg-rewind {
  background: #F7D44C;
  color: #2B2100;
  border-color: #D4A917;
}

.emerg-chill {
  background: rgba(8, 56, 92, 0.9);
  color: #E0FBFC;
  border-color: rgba(144, 224, 239, 0.45);
}

/* ==========================================================================
   Right-Side Scrollbar "Drain Valve"
   ========================================================================== */
.drain-track {
  position: fixed;
  top: 0;
  right: 0;
  width: 26px;
  height: 100vh;
  background: #EAE5DC;
  border-left: 1px solid #D8D1C5;
  z-index: 460;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.8s ease;
}

body.theme-dark .drain-track {
  background: #232730;
  border-left-color: #363C47;
}

body.phase-flood .drain-track {
  background: #E0E8F0;
  border-left-color: #B4C6D6;
}

body.theme-dark.phase-flood .drain-track {
  background: #1C2733;
  border-left-color: #364B61;
}

body.phase-submerged .drain-track {
  background: #083354 !important;
  border-left-color: rgba(144, 224, 239, 0.25);
}

.drain-track-label {
  position: absolute;
  top: 66px;
  writing-mode: vertical-rl;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
  pointer-events: none;
}

body.phase-flood .drain-track-label { color: #0B4F8A; font-weight: 700; }
body.theme-dark.phase-flood .drain-track-label { color: #72D2F5; }

.drain-thumb {
  position: absolute;
  top: 60px;
  left: 3px;
  width: 20px;
  height: 92px;
  border-radius: 10px;
  background: #B8B1A6;
  cursor: ns-resize;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

body.phase-flood .drain-thumb {
  background: linear-gradient(180deg, #2A7BBF, #13558C);
  box-shadow: 0 2px 8px rgba(11, 79, 138, 0.35);
}

body.phase-flood .drain-thumb.draining {
  background: linear-gradient(180deg, #00D2FF, #0077B6);
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.78);
}

.thumb-grip {
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
}

.drain-grate {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 26px;
  height: 82px;
  background: #232B33;
  border-top: 2px solid #4A5968;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 8px;
}

.grate-slats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.grate-slats span {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: #12171D;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.drain-grate.open .grate-slats span {
  background: #00E5FF;
  box-shadow: 0 0 8px #00E5FF;
}

.grate-status {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: #9FB0C0;
}

.drain-grate.open .grate-status { color: #6FFFE9; }

.drain-clog-indicator {
  position: absolute;
  bottom: 92px;
  right: 32px;
  background: #E85D4A;
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 6px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232, 93, 74, 0.5);
  animation: bounceLeft 0.65s ease-in-out infinite alternate;
}

@keyframes bounceLeft {
  from { transform: translateX(0); }
  to { transform: translateX(-6px); }
}

/* ==========================================================================
   Dynamic Events: Cookie Banner, Sponge Ad & Newsletter Shield
   ========================================================================== */
.cookie-banner {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, calc(100vw - 60px));
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 14px 36px rgba(28, 27, 25, 0.2);
  z-index: 430;
  animation: slideUpBanner 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpBanner {
  from { transform: translate(-50%, 80px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.cookie-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.cookie-icon { font-size: 22px; }
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }

.cookie-btn {
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.cookie-accept {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: var(--bg-paper);
}

/* Tacky Sponge Ad Popup */
.ad-sponge-popup {
  position: fixed;
  right: 42px;
  bottom: 24px;
  width: 310px;
  background: #FFFDF0;
  color: #1C1B19;
  border: 2px solid #E5A910;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
  z-index: 435;
  animation: popInRight 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popInRight {
  from { transform: translateX(60px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.ad-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  background: #E85D4A;
  color: #FFF;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.ad-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  color: #888;
  cursor: pointer;
}

.ad-body {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.ad-sponge-icon { font-size: 32px; }
.ad-body h4 { font-size: 13px; margin-bottom: 3px; }
.ad-body p { font-size: 11.5px; color: #56524B; line-height: 1.4; }

.ad-claim-btn {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 7px;
  background: linear-gradient(90deg, #F5B700, #E8871E);
  color: #2B1A00;
  font-weight: 700;
  font-size: 12.5px;
  font-family: var(--font-sans);
  cursor: pointer;
}

.ad-claim-btn:hover { filter: brightness(1.06); }

/* Newsletter Shield */
.newsletter-modal {
  position: fixed;
  top: 28%;
  left: 50%;
  width: 320px;
  background: var(--bg-card);
  border: 2px solid var(--ink-primary);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 18px 42px rgba(11, 79, 138, 0.25);
  z-index: 280;
  cursor: grab;
}

.newsletter-modal:active { cursor: grabbing; }

.modal-close-x {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink-muted);
  cursor: pointer;
}

.shield-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  background: #00A6ED;
  color: #FFF;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.newsletter-modal h4 { font-family: var(--font-serif); font-size: 17px; margin-bottom: 6px; }
.newsletter-modal p { font-size: 12px; color: var(--ink-secondary); line-height: 1.5; margin-bottom: 10px; }

.fake-input-row { display: flex; gap: 6px; }

.fake-input-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-hairline);
  border-radius: 5px;
  font-size: 12px;
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.fake-sub-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  background: var(--ink-primary);
  color: var(--bg-paper);
  font-size: 12px;
  cursor: pointer;
}

/* ==========================================================================
   Toasts, Debris & Underwater Dock
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  z-index: 520;
  pointer-events: none;
}

.game-toast {
  background: rgba(24, 28, 34, 0.9);
  color: #F6F3EC;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.game-toast.toast-alert { background: rgba(186, 45, 36, 0.93); }
.game-toast.toast-zen {
  background: rgba(11, 79, 138, 0.9);
  border: 1px solid rgba(144, 224, 239, 0.38);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.debris-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 325;
}

.ascii-debris {
  position: absolute;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
  pointer-events: none;
  will-change: transform, opacity;
}

.underwater-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 34, 58, 0.85);
  border: 1px solid rgba(144, 224, 239, 0.34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  z-index: 500;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  animation: slideUpBanner 0.6s ease;
}

.dock-hint { font-size: 12px; color: rgba(202, 240, 248, 0.84); }
.dock-buttons { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }

.dock-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(144, 224, 239, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #E0FBFC;
  font-size: 12.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dock-btn:hover { background: rgba(255, 255, 255, 0.22); transform: translateY(-1px); }

.dock-btn-primary {
  background: #00B4D8;
  border-color: #48CAE4;
  color: #031B2E;
  font-weight: 700;
}

.dock-btn-primary:hover { background: #48CAE4; }

/* ==========================================================================
   Ending & 8-Endings Gallery Modals
   ========================================================================== */
.ending-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 18, 30, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.ending-card {
  width: min(840px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  background: #F6F3EC;
  color: #1C1B19;
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
}

.ending-header { text-align: center; margin-bottom: 14px; }

.ending-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  background: #1C1B19;
  color: #F6F3EC;
  padding: 3px 11px;
  border-radius: 999px;
  margin-bottom: 7px;
}

.ending-header h2 { font-family: var(--font-serif); font-size: 27px; margin-bottom: 5px; }
.ending-desc { font-size: 13.5px; color: #56524B; line-height: 1.55; }

.postcard-preview-wrap {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #D8D2C6;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
  margin-bottom: 15px;
  background: #FFF;
}

#postcard-canvas { display: block; width: 100%; height: auto; }

.ending-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: #FFFFFF;
  border: 1px solid #E2DDD2;
  border-radius: 8px;
  padding: 9px 8px;
  text-align: center;
}

.stat-label { display: block; font-size: 11px; color: #8B857B; margin-bottom: 3px; }
.stat-box strong { font-family: var(--font-mono); font-size: 15px; color: #1C1B19; }

.ending-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.end-btn {
  padding: 9px 17px;
  border-radius: 8px;
  border: 1px solid #D4CEC2;
  background: #FFFFFF;
  color: #1C1B19;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
}

.end-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.end-btn-primary { background: #0B4F8A; border-color: #0B4F8A; color: #FFF; }
.end-btn-primary:hover { background: #0D63AD; }
.end-btn-outline { background: transparent; border-color: #1C1B19; }

/* Collectible Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.gallery-item {
  background: #FFFFFF;
  border: 1px solid #E2DDD2;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery-item.locked {
  background: #EFECE4;
  opacity: 0.72;
}

.gallery-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-item-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
}

.gallery-status {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #D8EFE3;
  color: #205B3E;
}

.gallery-item.locked .gallery-status {
  background: #DDD8CE;
  color: #6B655D;
}

.gallery-item-hint {
  font-size: 12px;
  color: #56524B;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .editorial-grid { grid-template-columns: 1fr; }
  .editorial-col-side { display: grid; grid-template-columns: 1fr 1fr; }
  .ending-stats { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid { grid-template-columns: 1fr; }
}
