@font-face {
  font-family: "Determination Mono";
  src: url("../DTM-Mono.otf") format("opentype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --accent: #fff;
  --textbox-text: #fff;
  --bg: #1a1a1a;
  --panel: #0a0a0a;
  --field: #000;
  --muted: #8a8a8a;
  --danger: #ff5a5a;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  font-family: "Determination Mono", ui-monospace, monospace;
  background: var(--bg);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: 20px;
  overflow: hidden;
  gap: 20px;
}

.terminal {
  background: var(--panel);
  border: 2px solid var(--accent);
  padding: 25px;
  width: 90vw;
  max-width: 1600px;
  max-height: 85vh;
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  min-height: 52px;
  flex-wrap: wrap;
  gap: 12px;
}

h1 {
  margin: 0;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 8px;
  flex: 1;
  min-width: 0;
  font-size: 1.55em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.form-group > span {
  display: block;
  margin-bottom: 6px;
  white-space: nowrap;
  font-size: 1.2em;
}

textarea,
.output-text {
  width: 100%;
  padding: 14px;
  background: var(--field);
  color: var(--textbox-text);
  border: 1px solid var(--accent);
  font-family: "Determination Mono", ui-monospace, monospace;
  resize: none;
  flex: 1;
  min-height: 60px;
  font-size: 1.35em;
  line-height: 1.3;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-text { user-select: text; }
.output-text:empty::before { content: attr(data-placeholder); opacity: 0.55; }
textarea::placeholder { color: var(--textbox-text); opacity: 0.55; }
.output-error { color: var(--danger); }
.chat-timestamp { color: var(--muted); }
.chat-username { font-weight: bold; }

.button-row { display: flex; gap: 12px; }

button {
  font-family: "Determination Mono", ui-monospace, monospace;
  font-weight: bold;
  cursor: pointer;
  font-size: 1.15em;
}
button:hover { filter: brightness(1.15); }

#copyButton,
#clearButton {
  flex: 1;
  padding: 16px;
}

#copyButton {
  background: var(--accent);
  color: #000;
  border: none;
  transition: background-color .15s ease, color .15s ease, opacity .15s ease;
}
#copyButton:disabled {
  background: #777;
  color: #222;
  opacity: .72;
  cursor: not-allowed;
  filter: none;
}
#copyButton.golden-shine {
  border: 1px solid #fff2a8;
  box-shadow: 0 0 10px rgba(245, 197, 66, .5), inset 0 0 6px rgba(255, 242, 168, .35);
}
#clearButton {
  background: #000;
  color: var(--accent);
  border: 1px solid var(--accent);
}

textarea:focus,
.output-text:focus,
button:focus {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.info-button {
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.info-button img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.lang-switch { display: flex; gap: 8px; }
.flag-container {
  cursor: pointer;
  padding: 5px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.flag-container.active { border-color: var(--accent); }
.flag-icon {
  display: block;
  width: 42px;
  height: 26px;
  object-fit: cover;
  border-radius: 2px;
}

.bottom-section {
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.credits,
.twitch {
  text-align: center;
  font-size: .95em;
  opacity: .85;
  color: var(--accent);
}
.credits a,
.twitch a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

.modal {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-content {
  background: #0a0a0a;
  border: 2px solid var(--accent);
  padding: 25px;
  max-width: 620px;
  width: 90%;
  color: var(--accent);
  font-size: 1.1em;
  line-height: 1.4;
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.8em;
  cursor: pointer;
  color: var(--accent);
  line-height: 1;
}

.status {
  margin: 0;
  color: var(--muted);
  min-height: 1.2em;
  font-size: .78em;
  line-height: 1.2;
}
.status.error { color: var(--danger); }

@media (max-width: 800px), (max-height: 700px) {
  body {
    justify-content: flex-start;
    align-items: stretch;
    min-height: 100dvh;
    padding: 10px;
    overflow: auto;
    gap: 12px;
  }

  .terminal {
    width: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    padding: 14px;
    overflow: visible;
  }

  .header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    margin-bottom: 14px;
    min-height: 0;
  }

  h1 {
    font-size: 1.05em;
    align-self: center;
  }

  .info-button {
    width: 34px;
    height: 34px;
    font-size: 1.1em;
  }

  .lang-switch { gap: 5px; }
  .flag-container { padding: 4px; }
  .flag-icon { width: 34px; height: 22px; }

  .content {
    flex: none;
    gap: 10px;
    min-height: auto;
  }

  .form-group {
    flex: none;
    min-height: auto;
  }

  .form-group > span {
    font-size: 1em;
    margin-bottom: 4px;
  }

  textarea,
  .output-text {
    flex: none;
    min-height: 0;
    height: 22dvh;
    max-height: 220px;
    padding: 10px;
    font-size: 1em;
    line-height: 1.25;
  }

  .button-row {
    flex-direction: column;
    gap: 8px;
  }

  #copyButton,
  #clearButton {
    padding: 12px;
    min-height: 46px;
  }

  .status { font-size: .68em; }
  .bottom-section { min-height: 0; gap: 3px; }
  .credits, .twitch { font-size: .78em; line-height: 1.25; }
}

@media (max-width: 380px) {
  .terminal { padding: 12px; }
  h1 { font-size: .92em; }
  .info-button { width: 32px; height: 32px; }
  .flag-icon { width: 30px; height: 20px; }
  textarea, .output-text { height: 20dvh; }
}
