:root {
  --bg-1: #1e130f;
  --bg-2: #332220;
  --gold: #f4ca64;
  --gold-deep: #b07e22;
  --panel: rgba(14, 11, 10, 0.85);
  --text: #f7f3ea;
  --danger: #ff5a5a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 20%, #46332b 0%, var(--bg-1) 46%, #0f0b0a 100%);
}

#app,
#game-container {
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 20;
}

.hud-card {
  min-width: 130px;
  background: var(--panel);
  border: 1px solid #523a2f;
  border-radius: 10px;
  padding: 8px 10px;
  backdrop-filter: blur(4px);
}

.label {
  font-size: 12px;
  color: #d1c4b2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.value {
  font-size: 24px;
  color: var(--gold);
  font-weight: 700;
}

.hint {
  background: var(--panel);
  border: 1px solid #523a2f;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  max-width: min(40vw, 500px);
}

.panel {
  position: fixed;
  width: min(26vw, 360px);
  height: min(42vh, 340px);
  background: var(--panel);
  border: 1px solid #5a4334;
  border-radius: 12px;
  padding: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.panel h3 {
  margin: 4px 0 8px;
  color: var(--gold);
}

#chat-panel {
  left: 14px;
  bottom: 12px;
}

#feed-panel {
  right: 14px;
  bottom: 12px;
}

#chat-messages,
#feed-messages {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 8px;
  overflow-y: auto;
  font-size: 13px;
}

#chat-messages p,
#feed-messages p {
  margin: 0 0 7px;
}

#chat-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

input,
button,
select {
  border: 1px solid #76563f;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  color: var(--text);
  background: #281d18;
}

input {
  flex: 1;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #b88b39, #7f5516);
  border-color: #b78c4b;
  font-weight: 700;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.58);
  z-index: 30;
  padding: 16px;
}

.hidden {
  display: none;
}

.modal-card {
  width: min(92vw, 520px);
  background: #1a130f;
  border: 1px solid #644933;
  border-radius: 14px;
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
}

#machine-body p {
  margin: 10px 0;
}

.inline-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.result {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed #806149;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

#toast {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid #c5a070;
  background: rgba(17, 10, 6, 0.95);
  color: #ffe8ba;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  text-align: center;
  min-width: 280px;
}

#toast.show {
  opacity: 1;
}

.danger {
  color: var(--danger);
}

@media (max-width: 980px) {
  #hud {
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
  }

  .hint {
    max-width: 100%;
  }

  .panel {
    width: calc(50vw - 14px);
    height: 32vh;
    bottom: 8px;
  }

  #chat-panel {
    left: 8px;
  }

  #feed-panel {
    right: 8px;
  }
}
