* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background-color: #f7f3e4;
  background-image: url("../../../MARGOSTORY_2/assets/paper-01.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  color: #5a3828;
  font-family: Manrope, "Noto Sans Hebrew", sans-serif;
  font-weight: 500;
}

button, a { font-family: inherit; }

#app {
  width: min(950px, 100%);
  margin: 0 auto;
  padding: 16px clamp(12px, 2vw, 28px) 24px;
}

.top {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

#back {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(251, 246, 238, 0.62);
  color: #4a3022;
  font-family: Lora, "Noto Serif Hebrew", Georgia, serif;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(90, 56, 40, 0.06);
  cursor: pointer;
}

.brand {
  justify-self: center;
}

.brand img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 50%;
}

.langs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.langs span { color: #b8924a; }

.langs button {
  min-height: 44px;
  padding: 8px 2px;
  border: 0;
  background: transparent;
  color: #8d735f;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.langs button[aria-pressed="true"] {
  color: #5a3828;
  text-decoration: underline;
  text-decoration-color: #c4a15a;
  text-underline-offset: 4px;
}

.hud {
  padding: clamp(16px, 3vw, 28px) clamp(14px, 3vw, 24px) 18px;
  border-radius: 22px;
  background: rgba(247, 241, 228, 0.86);
  box-shadow: 0 10px 28px rgba(90, 56, 40, 0.05);
}

#title {
  margin: 0 0 12px;
  text-align: center;
  font-family: Lora, "Noto Serif Hebrew", Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 600;
  color: #5a3828;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.toolbar button,
#keys button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid rgba(196, 161, 90, 0.85);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.92);
  color: #5a3828;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.toolbar button:disabled,
#keys button:disabled {
  cursor: default;
}

#btn-hint[aria-pressed="true"] {
  background: #c4a15a;
  border-color: #b8924a;
  color: #fffaf3;
}

#word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  margin: 16px 0 8px;
}

#word span {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 56px;
  padding: 0 6px;
  border-radius: 12px;
  border: 1px solid rgba(196, 161, 90, 0.8);
  background: rgba(255, 250, 243, 0.95);
  color: #4a3022;
  font-family: Lora, "Noto Serif Hebrew", Georgia, serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
}

#word span.hidden { color: transparent; }

#wrong {
  min-height: 1.5em;
  margin: 0 0 8px;
  text-align: center;
  color: #6e5646;
  font-size: 1rem;
}

#wrong s {
  display: inline-block;
  margin: 0 0.2em;
  color: #8d6848;
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration-thickness: 2px;
}

#result {
  min-height: 1.4em;
  margin: 0 0 10px;
  text-align: center;
  color: #5a3828;
  font-weight: 600;
}

#toast {
  margin: 0 0 12px;
  padding: 12px 12px 14px;
  border-radius: 16px;
  background: rgba(255, 250, 243, 0.9);
  border: 1px solid rgba(196, 161, 90, 0.55);
  text-align: center;
}

#toast[hidden] { display: none; }

#toast-title,
#toast-line,
#toast-word {
  margin: 0 0 6px;
}

#toast-title {
  font-family: Lora, "Noto Serif Hebrew", Georgia, serif;
  font-size: 1.45rem;
}

#toast-word {
  font-size: 1.35rem;
  letter-spacing: 0.12em;
}

#keys {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 6px;
}

#keys button {
  min-width: 0;
  padding: 0;
  border-radius: 10px;
  font-size: 1rem;
}

#keys button.right:disabled {
  opacity: 1;
  background: #5a3828;
  border-color: #5a3828;
  color: #fffaf3;
}

#keys button.wrong:disabled {
  opacity: 1;
  background: rgba(231, 214, 196, 0.9);
  color: #8d6848;
  text-decoration: line-through;
}

#status {
  margin: 8px 0 0;
  text-align: center;
  color: #6e5646;
  font-size: 0.9rem;
}

#status[hidden] { display: none; }

#view {
  display: block;
  width: 100%;
  height: min(52dvh, 560px);
  min-height: 240px;
  margin-top: 14px;
  border-radius: 22px;
  touch-action: none;
}

html[dir="rtl"] .langs { direction: ltr; }

@media (max-width: 720px) {
  #app { padding-top: 10px; }
  .brand img { width: 52px; height: 52px; }
  #back { width: 44px; height: 44px; }
  #word span { min-width: 40px; height: 52px; }
  #view { height: 42dvh; min-height: 220px; }
}
