*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --background: #111111;
  --surface: #1a1a1a;
  --control: #2e2e2e;
  --border: #3a3a3a;
  --muted: #6a6a6a;
  --focus: #7a7a7a;
  --label: #8a8a8a;
  --text: #e8e8e8;
  --success: #3ddc84;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem;
  background: var(--background);
  color: var(--text);
  font-family:
    ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", "JetBrains Mono",
    Menlo, Consolas, monospace;
}

#text {
  margin: 0;
  max-width: 42rem;
  font-size: 1.5rem;
  line-height: 1.6;
  text-align: center;
}

#input {
  width: min(42rem, 100%);
  padding: 0.35rem 0.15rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.25rem;
  text-align: center;
  outline: none;
  caret-color: var(--text);
}

#text .correct {
  color: var(--success);
}

#text .mistake {
  color: #e86f6f;
}

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

#timer {
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

#hints {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

#hint,
#switch-hint {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#switch-hint {
  color: #505050;
}

#text.done,
#timer.done {
  color: var(--success);
}

#random-phrases,
#share {
  position: fixed;
  top: 1rem;
  border: none;
  background: var(--control);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  border-radius: 3px;
}

#random-phrases {
  left: 1rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

#share {
  right: 1rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 0;
}

#random-phrases:hover,
#share:hover {
  color: var(--text);
}

#share-dialog {
  width: min(36rem, calc(100vw - 2rem));
  padding: 1.25rem 1.35rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

#share-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

#share-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

#share-form label {
  font-size: 0.85rem;
  color: var(--label);
  letter-spacing: 0.04em;
}

#share-phrase {
  width: 100%;
  resize: none;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--background);
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  outline: none;
}

#share-phrase:focus {
  border-color: var(--focus);
}

#share-count {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#share-count.limit {
  color: #e8a0a0;
}

#share-link-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

#share-link {
  min-width: 0;
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--background);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  outline: none;
}

#share-link:focus {
  border-color: var(--focus);
}

#share-link.copied {
  border-color: var(--success);
}

#share-copy {
  flex: none;
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 3px;
  background: var(--control);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

#share-copy:disabled {
  color: var(--muted);
  cursor: default;
}

#share-copy:not(:disabled):hover {
  color: #ffffff;
}

#share-copy.copied {
  color: var(--success);
}
