@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

/* ====== Design Tokens ====== */
:root {
  --bk-bg:         #0e1117;
  --bk-surface:    #121621;
  --bk-surface-2:  #0f131d;
  --bk-text:       #fafafa;
  --bk-subtle:     #b9c0cf;
  --bk-accent:     #ffdd33;
  --bk-accent-ink: #000;

  --s-4:  4px;
  --s-6:  6px;
  --s-8:  8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-20: 20px;
  --s-24: 24px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-1: 0 6px 20px rgba(0,0,0,.25);
}

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

/* ====== Top accent bar ====== */
html {
  border-top: 4px solid var(--bk-accent);
}

/* ====== Base ====== */
body {
  background: var(--bk-bg);
  color: var(--bk-text);
  font-family: 'Open Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* ====== Layout ====== */
.container {
  max-width: 1400px;
  width: 60%;
  margin: 0 auto;
  padding: var(--s-20);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
  overflow: hidden;
}

.card {
  background: var(--bk-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--s-16);
  margin-top: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ====== Hero banner ====== */
.hero {
  border: 10px solid #1d212a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #f7da21;
  box-shadow: var(--shadow-1);
  margin: 0;
}

.hero__img {
  width: 100%;
  aspect-ratio: 6 / 1;
  background: #f7da21 center / contain no-repeat;
}

/* ====== Subtitle & meta row ====== */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-8);
  margin: 0;
  flex-shrink: 0;
  padding: var(--s-8) var(--s-12);
  background: var(--bk-surface-2);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius-sm);
}

.subtitle-container {
  color: var(--bk-accent);
  font-weight: 700;
}

/* ====== Inputs ====== */
.input-container { margin: var(--s-8) 0; }

.input-container label {
  display: block;
  margin-bottom: var(--s-4);
  color: var(--bk-subtle);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
.custom-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid #000;
  background: #fff;
  color: #000;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input[type="text"]:focus,
.custom-input:focus {
  outline: none;
  border-color: var(--bk-accent);
  box-shadow: 0 0 0 3px rgba(255,221,51,.35);
}

/* ====== Submit button ====== */
.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-width: 180px;
  background: linear-gradient(to bottom, #fffe22, #cccb1b);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 28px;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
  transition: filter .1s ease, transform .05s ease, box-shadow .05s ease;
  margin-top: var(--s-8);
}

.submit-button:hover  { filter: brightness(1.08); }
.submit-button:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }

/* ====== Loading spinner ====== */
#loading {
  display: none;
  width: 32px;
  height: 32px;
  margin: var(--s-16) auto;
  border: 3px solid rgba(255,221,51,.2);
  border-top-color: var(--bk-accent);
  border-radius: 50%;
  animation: bk-spin .7s linear infinite;
}

@keyframes bk-spin {
  to { transform: rotate(360deg); }
}

/* ====== Results ====== */
.summary-count { margin: var(--s-6) 0 var(--s-8); flex-shrink: 0; }

.count-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--bk-surface-2);
  border: 1px solid rgba(255,255,255,.06);
  color: var(--bk-accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.matching-words {
  animation: bk-fadein .25s ease;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: var(--s-4);
  scrollbar-width: thin;
  scrollbar-color: var(--bk-accent) var(--bk-surface-2);
}

.matching-words::-webkit-scrollbar { width: 6px; }
.matching-words::-webkit-scrollbar-track { background: var(--bk-surface-2); border-radius: 3px; }
.matching-words::-webkit-scrollbar-thumb { background: var(--bk-accent); border-radius: 3px; }
.matching-words::-webkit-scrollbar-thumb:hover { background: #fffe22; }

@keyframes bk-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Letter groups */
.letter-group { margin-bottom: var(--s-12); }

.letter-heading {
  display: flex;
  align-items: baseline;
  gap: var(--s-8);
  margin-bottom: var(--s-4);
}

.letter-char {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--bk-text);
  line-height: 1;
}

.letter-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bk-accent);
  background: rgba(255,221,51,.1);
  border: 1px solid rgba(255,221,51,.25);
  border-radius: 20px;
  padding: 2px 9px;
}

.word-length-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.length-label {
  font-size: 0.68rem;
  color: var(--bk-subtle);
  font-weight: 700;
  min-width: 18px;
  opacity: 0.6;
}

.word-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--bk-text);
  transition: background .1s ease;
}

.word-chip:hover { background: rgba(255,255,255,.1); }

.word-chip.pangram {
  background: rgba(255,221,51,.12);
  border-color: rgba(255,221,51,.35);
  color: var(--bk-accent);
  font-weight: 900;
}

.error-message {
  color: #ff6b6b;
  font-size: 14px;
  margin-top: var(--s-4);
}

/* ====== Footer ====== */
footer { flex-shrink: 0; margin-top: var(--s-12); }

#copyright {
  color: var(--bk-subtle);
  font-size: 0.8rem;
}

#copyright a,
#copyright a:visited {
  color: inherit;
  text-decoration: none;
}

.wordlist-updated {
  font-size: 0.8rem;
  color: var(--bk-accent);
  font-weight: 400;
  font-style: italic;
  opacity: 0.8;
}

/* ====== Beer widget ====== */
.beer-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: rgba(0,0,0,0.8);
    border: 1px solid var(--bk-accent);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    box-shadow: 0 0 15px rgba(255,221,51,0.2);
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(5px);
}
.beer-icon {
    font-size: 30px;
    line-height: 1;
    filter: drop-shadow(0 0 5px rgba(255,200,0,0.5));
    transition: transform 0.3s;
}
.beer-widget::before {
    content: "Buy me a beer?";
    position: absolute;
    right: 70px;
    background: #000;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.7rem;
    border: 1px solid #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateX(10px);
    white-space: nowrap;
}
.beer-widget:hover {
    transform: scale(1.1) rotate(-10deg);
    background: var(--bk-accent);
    box-shadow: 0 0 25px var(--bk-accent);
    border-color: #fff;
}
.beer-widget:hover::before {
    opacity: 1;
    transform: translateX(0);
}

/* ====== Back nav ====== */
.nav-back {
    position: fixed; top: 1.25rem; left: 1.25rem; z-index: 100;
    text-decoration: none; font-family: 'Open Sans', sans-serif;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em;
    text-transform: uppercase; color: rgba(250,250,250,0.7);
    transition: color 0.2s;
}
.nav-back:link,
.nav-back:visited { color: rgba(250,250,250,0.7); }
.nav-back:hover { color: var(--bk-accent); }

/* ====== Responsive ====== */
@media (max-width: 900px) {
  .container { width: 92%; height: auto; overflow: visible; }
  body { overflow: auto; }
  .card { flex: none; overflow: visible; }
  .matching-words { overflow: visible; flex: none; }
}
