/* よるのふね — CRT world foundation
   palette: 夜霧 / 深瀬 / 群青 / 藍鉄 / 星灯 / 月白 / 灯火 / 信号灯 */

@font-face {
  font-family: 'DotGothic16';
  src: url('../fonts/DotGothic16.woff2') format('woff2'),
       url('../fonts/DotGothic16.ttf') format('truetype');
  font-display: swap;
}

:root {
  --night: #0a0e1a;
  --deep: #131a30;
  --indigo: #1e2a4a;
  --steel: #2e4066;
  --starlight: #e8e4d6;
  --moon: #f4f1e4;
  --lantern: #ffcf6a;
  --signal: #7ee8d0;
  --gm: #ff0080;
  --gc: #00e0e0;
}

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

html { background: var(--night); }

body {
  font-family: 'DotGothic16', 'Hiragino Kaku Gothic ProN', monospace;
  color: var(--starlight);
  background: var(--night);
  font-size: 16px;
  line-height: 1.9;
  min-height: 100vh;
  overflow-x: hidden;
  /* 分かち書き前提: 折返しはスペース・句読点でだけ (単語の中で割らない) */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

img { image-rendering: pixelated; max-width: 100%; }

/* ---- CRT layer ---- */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9000;
  background:
    radial-gradient(ellipse 130% 110% at 50% 45%, transparent 62%, rgba(2,4,10,.55) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
  animation: crt-breathe 9s ease-in-out infinite;
}
@keyframes crt-breathe {
  0%, 100% { opacity: 1; } 50% { opacity: .93; }
}

#sky {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: -1;
}

/* ---- layout ---- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 28px);
}

/* ---- hero wordmark ---- */
.hero { text-align: center; padding: clamp(28px, 7vh, 64px) 0 clamp(10px, 2vh, 20px); }
.hero .title {
  font-size: clamp(44px, 12vw, 92px);
  letter-spacing: .06em;
  color: var(--moon);
  text-shadow:
    0 0 18px rgba(126, 232, 208, .25),
    4px 4px 0 rgba(6, 8, 16, .9);
  line-height: 1.25;
}
.hero .sub {
  color: var(--steel);
  font-size: clamp(13px, 2.6vw, 16px);
  letter-spacing: .5em;
  text-indent: .5em;
  margin-top: 6px;
  white-space: nowrap;
}
@media (max-width: 540px) {
  .hero .sub { letter-spacing: .14em; text-indent: .14em; font-size: 12px; }
}
.hero .lantern-dot { color: var(--lantern); text-shadow: 0 0 10px rgba(255,207,106,.7); }

/* ---- pixel box ---- */
.px-box {
  background: linear-gradient(180deg, var(--deep), #0e1428);
  border: 2px solid var(--moon);
  box-shadow: 4px 4px 0 0 rgba(0, 0, 0, .6);
  padding: 14px 16px;
  margin: 18px 0;
}
.px-box.dim { border-color: var(--steel); }
.px-box.signal { border-color: var(--signal); }

h2.sec {
  color: var(--lantern);
  font-size: 20px;
  margin: 30px 0 6px;
  border-bottom: 2px dotted var(--steel);
  padding-bottom: 4px;
}
h2.sec::before { content: '◆ '; color: var(--steel); }

/* ---- menu ---- */
.menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
@media (max-width: 540px) { .menu { grid-template-columns: repeat(2, 1fr); } }
.px-btn {
  display: block;
  text-align: center;
  padding: 12px 6px;
  color: var(--starlight);
  background: var(--deep);
  border: 2px solid var(--moon);
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, .6);
  text-decoration: none;
  transition: none;
}
.px-btn:hover, .px-btn:focus {
  background: var(--moon);
  color: var(--night);
  outline: none;
}
.px-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 rgba(0,0,0,.6); }

a { color: var(--signal); }
a:hover { background: var(--signal); color: var(--night); text-decoration: none; }

/* ---- ticker ---- */
.ticker {
  border-top: 2px solid var(--steel);
  border-bottom: 2px solid var(--steel);
  overflow: hidden;
  white-space: nowrap;
  color: var(--lantern);
  font-size: 14px;
  padding: 3px 0;
}
.ticker span {
  display: inline-block;
  padding-left: 100%;
  animation: tick 26s linear infinite;
}
@keyframes tick { to { transform: translateX(-100%); } }

/* ---- news list ---- */
.news dt { color: var(--steel); float: left; width: 6.4em; }
.news dd { margin-left: 7em; margin-bottom: 6px; }

/* ---- counter / footer ---- */
.counter {
  display: inline-block;
  background: #05070e;
  border: 2px solid var(--steel);
  padding: 2px 8px;
  color: var(--lantern);
  letter-spacing: .35em;
  font-size: 15px;
}
footer {
  margin: 44px 0 26px;
  text-align: center;
  color: var(--steel);
  font-size: 13px;
}
.banner88 {
  display: inline-block;
  width: 88px; height: 31px;
  border: 1px solid var(--steel);
  color: var(--steel);
  font-size: 11px;
  line-height: 29px;
  text-align: center;
  text-decoration: none;
  background: var(--deep);
}

/* ---- tables (faq/spec) ---- */
table.px { border-collapse: collapse; width: 100%; margin: 10px 0; }
table.px th, table.px td {
  border: 1px solid var(--steel);
  padding: 6px 10px;
  text-align: left;
  font-weight: normal;
}
table.px th { background: var(--indigo); color: var(--moon); white-space: nowrap; }
table.px td img { vertical-align: middle; }

/* ---- gallery ---- */
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .shots { grid-template-columns: 1fr; } }
.shot { text-align: center; }
.shot img {
  width: 100%;
  border: 2px solid var(--steel);
  box-shadow: 4px 4px 0 0 rgba(0, 0, 0, .6);
  cursor: default;
}
.shot .cap { font-size: 13px; color: var(--steel); margin-top: 4px; }
.shot.broken img { cursor: pointer; border-color: var(--gm); }
.shot.broken .cap { color: var(--gm); }

/* ---- glitch text ---- */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-t);
  position: absolute; left: 0; top: 0;
  width: 100%;
  opacity: 0;
}
.glitch::before { color: var(--gm); animation: gl1 6.5s infinite steps(1); }
.glitch::after  { color: var(--gc); animation: gl2 6.5s infinite steps(1); }
@keyframes gl1 {
  0%, 91%, 94.5%, 100% { opacity: 0; transform: none; clip-path: none; }
  91.5% { opacity: .85; transform: translate(-2px, 1px); clip-path: inset(20% 0 55% 0); }
  93%   { opacity: .85; transform: translate(2px, -1px); clip-path: inset(60% 0 15% 0); }
}
@keyframes gl2 {
  0%, 91.2%, 94.8%, 100% { opacity: 0; transform: none; clip-path: none; }
  92%  { opacity: .85; transform: translate(2px, -1px); clip-path: inset(45% 0 30% 0); }
  93.8%{ opacity: .85; transform: translate(-2px, 1px); clip-path: inset(8% 0 70% 0); }
}
.anomaly { color: var(--signal); }

.mojibake {
  margin-top: 26px;
  color: var(--steel);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  animation: moji-flicker 3.1s infinite steps(1);
}
@keyframes moji-flicker {
  0%, 74%, 82%, 100% { opacity: .55; }
  76% { opacity: .15; }
  78% { opacity: .8; color: var(--gm); }
  80% { opacity: .3; }
}

/* ---- terminal (404 / cabin / embark) ---- */
.term-page { background: #05070e; }
.term {
  max-width: 640px;
  margin: 6vh auto;
  padding: clamp(14px, 3vw, 30px);
  border: 2px solid var(--signal);
  box-shadow: 0 0 24px rgba(126, 232, 208, .12), 4px 4px 0 0 rgba(0,0,0,.7);
  background: rgba(8, 12, 22, .92);
  min-height: 60vh;
}
.term .out {
  color: var(--signal);
  text-shadow: 0 0 8px rgba(126, 232, 208, .35);
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
  min-height: 8em;
}
.term .out .said { color: var(--starlight); text-shadow: none; }
.cursor::after {
  content: '▊';
  animation: blink 1.05s infinite steps(1);
  color: var(--signal);
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.term-form { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.term-input {
  flex: 1;
  min-width: 180px;
  background: #05070e;
  border: 2px solid var(--steel);
  color: var(--moon);
  font-family: inherit;
  font-size: 18px;
  padding: 8px 10px;
  letter-spacing: .1em;
}
.term-input:focus { outline: none; border-color: var(--signal); }
.term-send {
  font-family: inherit;
  font-size: 16px;
  background: var(--deep);
  color: var(--starlight);
  border: 2px solid var(--moon);
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, .6);
  padding: 8px 18px;
  cursor: pointer;
}
.term-send:hover { background: var(--moon); color: var(--night); }
.term-send:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 rgba(0,0,0,.6); }

.shake { animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

#static-canvas { display: block; width: 100%; height: 130px; margin-bottom: 12px; }

/* ---- star map ---- */
#starmap {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 14px auto;
  border: 2px solid var(--steel);
  background: var(--night);
  cursor: crosshair;
  touch-action: manipulation;
}

/* ---- ending ---- */
#ending-canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border: 2px solid var(--steel);
  background: var(--night);
}
.cert {
  text-align: center;
  border: 2px solid var(--lantern);
  box-shadow: 0 0 26px rgba(255, 207, 106, .14), 4px 4px 0 0 rgba(0,0,0,.7);
  background: linear-gradient(180deg, #141a2e, #0d1224);
  padding: 26px 18px;
  margin: 22px auto;
  max-width: 460px;
}
.cert .big { font-size: clamp(24px, 6vw, 34px); color: var(--lantern); letter-spacing: .18em; text-indent: .18em; }
.cert .name { font-size: clamp(20px, 5vw, 28px); color: var(--moon); margin: 10px 0; }
.cert .row { color: var(--steel); font-size: 14px; }
.cert .row b { color: var(--signal); font-weight: normal; }

.hidden { display: none !important; }
.fade-in { animation: fadein 1.6s both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.note-s { color: var(--steel); font-size: 13px; }
.dim { color: var(--steel); }

/* ---- v2 ---- */
.tk { color: var(--signal); text-shadow: 0 0 8px rgba(126, 232, 208, .65); font-weight: normal; }
.ink { color: transparent; user-select: text; -webkit-user-select: text; }
.ink::selection { color: var(--moon); background: rgba(126, 232, 208, .35); }
.ink::-moz-selection { color: var(--moon); background: rgba(126, 232, 208, .35); }
.frag-box { white-space: pre-wrap; }
.bbspost { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dotted var(--steel); }
.kaiseki-sec { border-top: 2px dotted var(--steel); margin-top: 16px; padding-top: 10px; }
.kaiseki-sec h3 { color: var(--lantern); font-size: 15px; font-weight: normal; margin-bottom: 6px; }
select.px-sel, input.px-inp {
  background: #05070e; border: 2px solid var(--steel); color: var(--moon);
  font-family: inherit; font-size: 14px; padding: 6px 8px; max-width: 100%;
}
.sector-line { font-size: 14px; margin: 3px 0; }
.sector-line .ok { color: var(--signal); }
.sector-line .ng { color: var(--steel); }
details.fragd { margin: 4px 0 8px; }
details.fragd summary { cursor: pointer; color: var(--lantern); font-size: 14px; }
details.fragd pre { white-space: pre-wrap; font-family: inherit; color: var(--starlight); font-size: 14px; margin: 6px 0 0 12px; }
.slot {
  display: inline-block; min-width: 2.2em; text-align: center;
  border: 2px solid var(--steel); background: #05070e;
  padding: 4px 8px; margin: 3px; color: var(--moon); cursor: pointer;
}
.slot.filled { border-color: var(--signal); }
.card {
  display: block; width: 100%; text-align: left;
  border: 2px solid var(--moon); background: var(--deep); color: var(--starlight);
  font-family: inherit; font-size: 14px; padding: 8px 10px; margin: 6px 0; cursor: pointer;
  box-shadow: 3px 3px 0 0 rgba(0,0,0,.6);
}
.card:disabled { opacity: .35; cursor: default; }
.card b { color: var(--lantern); }
.small { font-size: 13px; }
.center { text-align: center; }
.amber { color: var(--lantern); }
