/* Taipan! - retro green-phosphor CRT look */

@font-face {
  font-family: "VT323";
  src: url("fonts/VT323-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --green: #3bff70;
  --green-dim: #1e9a44;
  --green-dark: #0d4020;
  --bg: #050d07;
}

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

html, body { height: 100%; }

body {
  background: #000;
  color: var(--green);
  font-family: "VT323", Consolas, "Courier New", monospace;
  font-size: 20px;
  line-height: 1.25;
  display: flex;
  justify-content: center;
}

#crt {
  position: relative;
  width: 100%;
  max-width: 860px;
  min-height: 100vh;
  padding: 18px 22px 30px;
  background: radial-gradient(ellipse at center, #07160b 0%, var(--bg) 75%);
  text-shadow: 0 0 6px rgba(59, 255, 112, 0.55);
}

/* scanlines */
#crt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px, rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px, rgba(0, 0, 0, 0) 4px);
}

.hidden { display: none !important; }

.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.inv, .warn {
  background: var(--green);
  color: #02180a;
  text-shadow: none;
  padding: 0 4px;
}

.right { float: right; }

/* ============ splash ============ */
#splash { text-align: center; padding-top: 5vh; }
#splash .art { display: inline-block; text-align: left; font-size: 18px; }
#splash .ship { margin-top: 18px; color: var(--green-dim); }
#splash .subtitle { margin-top: 8px; }
#splash .credits { margin: 22px 0 10px; color: var(--green-dim); }
#splash .blink { font-size: 22px; margin-top: 12px; }
#resume-hint {
  margin-top: 14px;
  display: inline-block;
  background: var(--green);
  color: #02180a;
  text-shadow: none;
  padding: 2px 10px;
}
.daily-hint { margin-top: 8px; color: var(--green-dim); }

#challenge-hint {
  margin-top: 14px;
  display: inline-block;
  background: var(--green);
  color: #02180a;
  text-shadow: none;
  padding: 2px 10px;
}

#topbar #mode-tag {
  color: var(--green);
  cursor: default;
  letter-spacing: 1px;
}
#topbar #mode-tag:hover { color: var(--green); }
#mode-tag:empty { display: none; }

/* ============ status board ============ */
#firm-line {
  text-align: center;
  margin-top: 26px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

/* ============ topbar & options ============ */
#topbar {
  position: absolute;
  top: 8px;
  right: 14px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  gap: 14px;
  font-size: 16px;
  color: var(--green-dim);
  user-select: none;
  z-index: 5;
}
#topbar span { cursor: pointer; }
#topbar span:hover { color: var(--green); }

#options-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#options-panel {
  background: var(--bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 24px rgba(59, 255, 112, 0.35);
  padding: 18px 24px;
  max-width: 460px;
  width: calc(100% - 40px);
}

#options-panel label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0;
  cursor: pointer;
  line-height: 1.2;
}

#options-panel input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin-top: 2px;
  border: 1px solid var(--green);
  background: transparent;
  cursor: pointer;
  position: relative;
}
#options-panel input[type="checkbox"]:checked::after {
  content: "X";
  color: var(--green);
  position: absolute;
  top: -4px;
  left: 3px;
  font-family: inherit;
  font-size: 18px;
}

#venture {
  grid-column: 1 / -1;
  border: 1px dashed var(--green-dark);
  padding: 4px 10px;
  color: var(--green-dim);
}
#venture .charter { color: var(--green); }

#pace {
  color: var(--green-dim);
  border-bottom: 1px solid var(--green-dark);
  margin-bottom: 4px;
  padding-bottom: 3px;
}

#journal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 16;
}

#journal-panel {
  background: var(--bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 24px rgba(59, 255, 112, 0.35);
  padding: 18px 24px;
  max-width: 560px;
  width: calc(100% - 40px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#journal-body {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dark) transparent;
}

#journal-body .line { margin: 4px 0; }
#journal-body .when { color: var(--green-dim); margin-right: 8px; }

#scores-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

#scores-panel {
  background: var(--bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 24px rgba(59, 255, 112, 0.35);
  padding: 18px 24px;
  max-width: 560px;
  width: calc(100% - 40px);
  max-height: 80vh;
  overflow-y: auto;
}

#scores-body .line { margin: 3px 0; white-space: nowrap; }
#scores-body .board-title {
  margin: 14px 0 6px;
  text-decoration: underline;
  letter-spacing: 1px;
}
#scores-body .empty { color: var(--green-dim); }

#ack-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#ack-panel {
  background: var(--bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 24px rgba(255, 120, 60, 0.35);
  padding: 18px 24px;
  max-width: 460px;
  width: calc(100% - 40px);
}

#ack-lines .line { margin: 6px 0; }
#ack-lines .head {
  text-decoration: underline;
  letter-spacing: 1px;
}
#ack-lines .warn { display: inline-block; }

#options-footer { text-align: right; margin-top: 16px; }

#options-footer button {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: inherit;
  font-size: 18px;
  padding: 4px 16px;
  cursor: pointer;
}
#options-footer button:hover {
  background: var(--green);
  color: #02180a;
  text-shadow: none;
}

#port-board {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 8px;
}

.board-left { display: flex; flex-direction: column; gap: 8px; }

.box {
  border: 1px solid var(--green-dim);
  padding: 6px 10px;
}

.box-title {
  color: var(--green);
  border-bottom: 1px solid var(--green-dark);
  margin-bottom: 4px;
  padding-bottom: 2px;
}

.goods { width: 100%; border-collapse: collapse; }
.goods td { padding: 1px 6px 1px 0; }
.goods td.num { text-align: right; min-width: 64px; }
.goods td.lbl { padding-left: 24px; color: var(--green-dim); }

.board-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.board-right .cell {
  border: 1px solid var(--green-dim);
  padding: 5px 8px;
  text-align: center;
  flex: 1;
}

.board-right .lbl { color: var(--green-dim); font-size: 13px; }

.board-bottom {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--green-dim);
  padding: 5px 12px;
}

#prices { grid-column: 1 / -1; }

#market { grid-column: 1 / -1; }
#market-toggle { cursor: pointer; user-select: none; }
#market-toggle:hover { color: var(--green); }
#market-arrow { float: right; color: var(--green-dim); }
#market-table td { font-size: 16px; padding-right: 10px; }
#market-table .market-head td {
  color: var(--green-dim);
  border-bottom: 1px solid var(--green-dark);
}
#market-table .market-here td { background: rgba(59, 255, 112, 0.12); }

/* ============ battle ============ */
#battle {
  border: 1px solid var(--green-dim);
  padding: 8px 12px;
  margin-top: 8px;
  background: rgba(6, 24, 12, 0.6);
}

#battle-top { display: flow-root; font-size: 17px; }
#battle-orders, #battle-status { margin-top: 3px; }

#lorchas {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px 14px;
  margin: 14px 0 6px;
  min-height: 132px;
}

.lorcha {
  font-family: inherit;
  white-space: pre;
  font-size: 16px;
  line-height: 1.1;
  min-height: 70px;
  color: var(--green);
}

.lorcha.hit { color: #ffb347; text-shadow: 0 0 8px rgba(255, 179, 71, 0.8); }

#b-more { color: var(--green-dim); }

@keyframes incoming-flash { 50% { background: rgba(255, 60, 30, 0.25); } }
#crt.incoming { animation: incoming-flash 0.18s 3; }

@keyframes shake {
  25% { transform: translate(3px, -2px); }
  50% { transform: translate(-3px, 2px); }
  75% { transform: translate(2px, 1px); }
}
#crt.incoming #battle { animation: shake 0.18s 3; }

/* ============ report / log ============ */
#report {
  margin-top: 10px;
  border: 1px solid var(--green-dim);
  padding: 8px 12px;
  height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dark) transparent;
}

#log .line { margin: 1px 0; }
#log .head {
  margin-top: 8px;
  color: var(--green);
  text-decoration: underline;
  letter-spacing: 1px;
}
#log .warn { display: inline-block; margin: 2px 0; }
#log .big {
  font-size: 22px;
  letter-spacing: 2px;
  margin: 6px 0;
}

#log .chart { margin: 8px 0; }
#log .chart svg {
  display: block;
  width: 100%;
  max-width: 460px;
  height: 100px;
  border: 1px solid var(--green-dark);
  background: rgba(6, 24, 12, 0.6);
}
.chart-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.5;
}
.chart-zero {
  stroke: var(--green-dark);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.chart-ghost {
  fill: none;
  stroke: var(--green-dim);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.chart-title { color: var(--green-dim); font-size: 15px; }

/* ============ prompt ============ */
#prompt-bar { margin-top: 10px; min-height: 96px; }

#prompt-text { font-size: 17px; }
#prompt-hint { color: var(--green-dim); margin-top: 2px; min-height: 20px; }

#prompt-buttons { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }

#prompt-buttons button {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: inherit;
  font-size: 19px;
  padding: 5px 14px;
  cursor: pointer;
  text-shadow: inherit;
}

#prompt-buttons button:hover, #prompt-buttons button:focus {
  background: var(--green);
  color: #02180a;
  text-shadow: none;
  outline: none;
}

#prompt-buttons button .key { text-decoration: underline; }

/* Consequential actions (e.g. Retire) sit alone at the far right so
   they can't be hit by accident. */
#prompt-buttons button.danger {
  margin-left: auto;
  border-color: var(--green-dim);
  color: var(--green-dim);
}
#prompt-buttons button.danger:hover,
#prompt-buttons button.danger:focus {
  background: var(--green-dim);
  color: #02180a;
}

#prompt-buttons button.cancel {
  border-color: var(--green-dim);
  color: var(--green-dim);
}
#prompt-buttons button.cancel:hover,
#prompt-buttons button.cancel:focus {
  background: var(--green-dim);
  color: #02180a;
}

#prompt-entry { margin-top: 6px; font-size: 20px; }

#prompt-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--green-dim);
  color: var(--green);
  font-family: inherit;
  font-size: 20px;
  width: 260px;
  text-shadow: inherit;
}
#prompt-input:focus { outline: none; border-bottom-color: var(--green); }

#prompt-pause { margin-top: 6px; font-size: 18px; }

@media (max-width: 640px) {
  body { font-size: 17px; }
  #crt { padding: 10px 10px 24px; }
  #port-board { grid-template-columns: 1fr; }
  .board-right { flex-direction: row; flex-wrap: wrap; }
  .board-right .cell { min-width: 45%; flex: 1 1 45%; }
  #lorchas { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .lorcha { font-size: 10px; min-height: 46px; }
  #splash .art { font-size: 11px; }
  #report { height: 150px; }
  /* Bigger touch targets */
  #prompt-buttons { gap: 10px; }
  #prompt-buttons button { padding: 10px 16px; min-width: 64px; }
  #prompt-input { width: 170px; }
}
