/* Colours picked from the logo (favicon.png) and the donkeys painting. */
:root {
  --purple-deep: #1c0633;        /* donkey body, darkest */
  --purple: #3b0f5c;
  --purple-light: #7a3fa8;       /* donkey highlights */
  --orange: #f78103;             /* painting background */
  --coral: #f2604a;              /* logo background */
  --cream: #fff4e6;              /* donkey muzzles / wings */
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--cream);
  background: var(--orange);
}

/* The painting sits on its own fixed layer so it stays put while the page
   scrolls (background-attachment: fixed doesn't work on phones). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, rgba(28, 6, 51, 0.55), rgba(28, 6, 51, 0) 45%),
    url("../assets/donkeys-painting.jpg") center bottom / cover no-repeat,
    var(--orange);
}

/* First screen: title bar + game, exactly one browser window tall. */
#screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--purple-deep);
  border-bottom: 4px solid var(--coral);
  box-shadow: 0 4px 20px rgba(28, 6, 51, 0.5);
}

/* EN / HE switch, pinned to the end of the title bar (right in English,
   left in Hebrew). */
#lang-toggle {
  position: absolute;
  inset-inline-end: 16px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 14px;
  font: bold 15px "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--purple-deep);
  background: var(--orange);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

#lang-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
}

.flag {
  height: 14px;
  width: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(28, 6, 51, 0.35);
}

/* Show the flag of the language the button switches to. */
html[lang="he"] .flag-il,
html[lang="en"] .flag-uk {
  display: none;
}

#lang-toggle:hover {
  background: var(--coral);
}

@media (max-width: 560px) {
  header {
    justify-content: flex-start;
  }
}

header img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--coral);
}

header h1 {
  margin: 0;
  font-size: clamp(18px, 3vw, 28px);
  letter-spacing: 0.04em;
  color: var(--orange);
  text-shadow: 2px 2px 0 var(--purple-light);
}

#stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The game's window, centered. SDL follows this element's size, so
   resizing the browser resizes the game too. */
#game-container {
  position: relative;
  width: 75vw;
  height: 75vh;
  max-height: calc(100% - 32px);
  background: var(--purple-deep);
  border: 6px solid var(--purple);
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px var(--coral),
    0 20px 60px rgba(28, 6, 51, 0.6);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  font: bold 28px "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  pointer-events: none;
  text-align: center;
  padding: 0 16px;
}

#scroll-hint {
  flex: none;
  align-self: center;
  margin-bottom: 12px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--purple-deep);
  color: var(--orange);
  font-weight: bold;
  text-decoration: none;
  border: 2px solid var(--coral);
}

#scroll-hint:hover {
  background: var(--purple);
}

/* ---- Cards below the game (chat, feedback) ---- */

.card {
  box-sizing: border-box;
  max-width: 640px;
  margin: 40px auto 80px;
  padding: 28px 24px;
  background: rgba(28, 6, 51, 0.92);
  border: 4px solid var(--coral);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(28, 6, 51, 0.6);
}

@media (max-width: 680px) {
  .card {
    margin-left: 16px;
    margin-right: 16px;
  }
}

.card h2 {
  margin: 0 0 6px;
  color: var(--orange);
  text-shadow: 2px 2px 0 var(--purple-light);
}

.card > p {
  margin: 0 0 20px;
}

#feedback-form label {
  display: block;
  margin: 14px 0 6px;
  font-weight: bold;
}

#feedback-form label .hint {
  font-weight: normal;
  opacity: 0.7;
}

#feedback-form input,
#feedback-form textarea,
#chat-form input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--cream);
  background: var(--purple);
  border: 2px solid var(--purple-light);
  border-radius: 8px;
}

#feedback-form textarea {
  resize: vertical;
}

#feedback-form input:focus,
#feedback-form textarea:focus,
#chat-form input:focus {
  outline: none;
  border-color: var(--orange);
}

#feedback-form button,
#chat-form button {
  margin-top: 18px;
  padding: 10px 28px;
  font: bold 18px "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--purple-deep);
  background: var(--orange);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

#feedback-form button:hover,
#chat-form button:hover {
  background: var(--coral);
}

#feedback-form .hidden-field {
  display: none;
}

#feedback-result {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--orange);
}

/* ---- Chat ---- */

#chat {
  max-width: 760px;
  margin-bottom: 0;
}

#chat-messages {
  height: 340px;
  overflow-y: auto;
  padding: 12px;
  background: rgba(59, 15, 92, 0.6);
  border: 2px solid var(--purple-light);
  border-radius: 10px;
}

.chat-msg {
  margin: 0 0 10px;
  padding: 8px 12px;
  max-width: 85%;
  width: fit-content;
  background: var(--purple);
  border-radius: 10px;
}

.chat-msg.mine {
  margin-inline-start: auto;
  background: #5a2183;
}

.chat-name {
  font-weight: bold;
  color: var(--orange);
}

.chat-time {
  margin-inline-start: 8px;
  font-size: 12px;
  opacity: 0.6;
}

.chat-text {
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-empty {
  margin: 0;
  text-align: center;
  opacity: 0.7;
}

#chat-status {
  min-height: 1.4em;
  margin: 8px 0;
  color: var(--orange);
}

#chat-form {
  display: flex;
  gap: 8px;
}

#chat-form #chat-name {
  flex: 0 0 140px;
}

#chat-form #chat-text {
  flex: 1;
  min-width: 0;
}

#chat-form button {
  flex: none;
  margin-top: 0;
}

@media (max-width: 560px) {
  #chat-form {
    flex-wrap: wrap;
  }

  #chat-form #chat-name {
    flex: 1 1 100%;
  }
}
