/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #FAF9F6;
  color: #1a1a1a;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

.hidden { display: none !important; }

/* ===== Turnstile Gate ===== */
#turnstile-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #FAF9F6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.turnstile-container {
  text-align: center;
  padding: 40px 24px;
}

.turnstile-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.turnstile-subtitle {
  color: #71717a;
  font-size: 14px;
  margin-bottom: 24px;
}

.turnstile-hint {
  color: #999;
  font-size: 12px;
  margin-top: 16px;
}

/* ===== Game App Shell ===== */
#game-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  border-left: 1px solid #e8e6e1;
  border-right: 1px solid #e8e6e1;
  background: #fff;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  position: relative;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  transition: background 0.2s;
  border: 1.5px solid #d1d5db;
}

.tab-human {
  background: #f0f0f0;
  color: #1a1a1a;
  border-right: none;
  border-radius: 10px 0 0 0;
}

.tab-human.active {
  background: #90EE90;
  border-color: #86efac;
}

.tab-larp {
  background: #f0f0f0;
  color: #1a1a1a;
  border-left: none;
  border-radius: 0 10px 0 0;
}

.tab-larp.active {
  background: #D8B4FE;
  border-color: #c084fc;
}

.credit-badge {
  position: absolute;
  top: 5px;
  right: 8px;
  background: #FDE68A;
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 10;
  line-height: 1.4;
}

/* ===== Announcement Banner ===== */
.announcement-banner {
  background: #4752c4;
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  position: relative;
  flex-shrink: 0;
}

.banner-text a {
  color: #fff;
  text-decoration: underline;
}

.banner-sub {
  font-size: 11px;
  opacity: 0.85;
}

.banner-close {
  position: absolute;
  top: 4px;
  right: 8px;
  color: #fff;
  font-size: 18px;
  opacity: 0.7;
  padding: 4px;
}

.banner-close:hover {
  opacity: 1;
}

/* ===== Human Tab - Chat ===== */
#content-human {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.robot-icon {
  font-size: 24px;
}

.chat-title {
  font-weight: 700;
  font-size: 15px;
}

.help-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #ccc;
  font-size: 12px;
  font-weight: 700;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn {
  color: #999;
  font-size: 13px;
  text-decoration: underline;
}

/* Chat Area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 40px 20px;
}

/* Chat Bubbles */
.chat-bubble-user {
  align-self: flex-end;
  max-width: 75%;
}

.chat-bubble-user .bubble-label {
  text-align: right;
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
}

.chat-bubble-user .bubble-body {
  background: #D1FAE5;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
}

.chat-bubble-ai {
  align-self: flex-start;
  max-width: 85%;
}

.chat-bubble-ai .bubble-label {
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
}

.chat-bubble-ai .bubble-body {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
}

.chat-bubble-ai .bubble-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.bubble-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.vote-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}

.vote-btn:hover {
  background: #f3f4f6;
}

.vote-btn.voted-up {
  background: #D1FAE5;
  border-color: #86efac;
}

.vote-btn.voted-down {
  background: #FEE2E2;
  border-color: #fca5a5;
}

.spam-hint {
  font-size: 11px;
  color: #999;
}

.btn-share {
  background: #4752c4;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
}

.btn-report {
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
}

/* Chat bubble for drawings */
.bubble-drawing {
  margin-bottom: 10px;
}

.bubble-drawing img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

/* Bottom Input */
.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid #f0f0f0;
  padding: 8px 16px 4px;
  background: #fff;
}

.input-sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.sub-tab {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  color: #555;
  border: 1.5px solid transparent;
}

.sub-tab.active {
  border-color: #1a1a1a;
}

.credit-warning {
  font-size: 12px;
  color: #ea580c;
  font-weight: 600;
  padding: 2px 0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #a3a3a3;
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  border: 1.5px solid #e5e7eb;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  color: #1a1a1a;
  border-color: #1a1a1a;
}

.action-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #22c55e;
  flex-shrink: 0;
  transition: background 0.15s;
}

.action-btn:hover {
  background: #16a34a;
}

.sponsor-line {
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 4px 0 8px;
}

.sponsor-line a {
  text-decoration: underline;
}

/* ===== Larp Tab ===== */
#content-larp {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}

.larp-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.larp-info-card {
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  background: #fafafa;
}

.larp-heading {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}

.larp-desc {
  font-size: 14px;
  color: #555;
  margin-bottom: 8px;
  line-height: 1.6;
}

.larp-meta {
  font-size: 13px;
  color: #999;
}

.btn-start-larp {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  background: #FFB6C1;
  color: #1a1a1a;
  border-radius: 10px;
  transition: background 0.15s, transform 0.1s;
}

.btn-start-larp:hover {
  background: #ffa0b0;
}

.btn-start-larp:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  background: #fff;
  color: #1a1a1a;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #f9fafb;
}

/* Larp Session */
.larp-prompt-card {
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: #fafafa;
  position: relative;
}

.larp-prompt-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.larp-prompt-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 12px;
}

.larp-timer {
  display: inline-block;
  background: #FDE68A;
  color: #1a1a1a;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 14px;
  border-radius: 20px;
}

.larp-timer.urgent {
  background: #ef4444;
  color: #fff;
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.larp-response-area {
  flex: 1;
}

.larp-textarea {
  width: 100%;
  min-height: 140px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.larp-textarea:focus {
  border-color: #a3a3a3;
}

.larp-session-tabs {
  display: flex;
  gap: 4px;
}

.btn-submit-larp {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  background: #22c55e;
  color: #fff;
  border-radius: 10px;
  transition: background 0.15s;
}

.btn-submit-larp:hover {
  background: #16a34a;
}

.btn-submit-larp:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* Larp Canvas */
.larp-canvas-area canvas {
  width: 100%;
  border: 2px solid #1a1a1a;
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #D8B4FE;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Gallery */
.back-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
}

.gallery-header {
  background: #DBEAFE;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.gallery-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gallery-empty {
  text-align: center;
  color: #999;
  font-size: 14px;
  padding: 20px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
}

.gallery-item {
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  background: #fff;
}

.gallery-item-prompt {
  font-size: 12px;
  color: #999;
  margin-bottom: 4px;
}

.gallery-item-response {
  font-size: 14px;
  font-weight: 500;
}

.gallery-item-drawing img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
}

/* ===== Draw Page ===== */
.draw-page {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #FAF9F6;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.draw-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.draw-title {
  font-size: 28px;
  font-weight: 700;
}

.draw-subtitle {
  font-size: 13px;
  color: #999;
}

.back-to-chat-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border: 1.5px solid #1a1a1a;
  border-radius: 8px;
  background: #fff;
  flex-shrink: 0;
}

.draw-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.draw-canvas-wrap canvas {
  width: 100%;
  max-width: 500px;
  max-height: 100%;
  border: 2px solid #1a1a1a;
  border-radius: 16px;
  background: #fff;
  touch-action: none;
}

.draw-colors {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 8px;
}

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.color-dot.active {
  border-color: #1a1a1a;
  transform: scale(1.15);
}

.draw-tools {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-bottom: 10px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
  background: #fff;
}

.tool-btn.active {
  border-color: #FDE68A;
  background: #FFFBEB;
}

.tool-btn.danger {
  background: #FFB6C1;
  border-color: #FFB6C1;
}

.tool-btn:hover {
  background: #f9fafb;
}

.tool-btn.danger:hover {
  background: #ffa0b0;
}

/* ===== Footer ===== */
.game-footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 8px 16px;
  border-top: 1px solid #f0f0f0;
  background: #FAF9F6;
}

.game-footer a {
  text-decoration: underline;
}

.online-counter {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  padding: 2px 0 6px;
  background: #FAF9F6;
}

/* ===== RAM Crisis Overlay ===== */
.ram-crisis-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(239, 68, 68, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ramFlash 0.3s ease;
}

@keyframes ramFlash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

.ram-crisis-content {
  text-align: center;
  color: #fff;
  padding: 40px 24px;
}

.ram-crisis-content h1 {
  font-size: 32px;
  margin-bottom: 12px;
}

.ram-crisis-content p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 24px;
}

.ram-crisis-content button {
  background: #fff;
  color: #ef4444;
  font-weight: 700;
  font-size: 16px;
  padding: 12px 32px;
  border-radius: 10px;
}

/* ===== Help Modal ===== */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.help-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.help-modal h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.help-modal p {
  font-size: 14px;
  color: #555;
  margin-bottom: 10px;
  line-height: 1.6;
}

.help-modal button {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 10px;
}

/* ===== Responsive ===== */
@media (min-width: 521px) {
  #game-app {
    max-width: 520px;
  }
}

@media (max-width: 520px) {
  #game-app {
    border: none;
    max-width: 100%;
  }

  .tab {
    font-size: 15px;
    padding: 12px 0;
  }

  .larp-heading {
    font-size: 20px;
  }

  .btn-start-larp {
    font-size: 16px;
    padding: 14px;
  }

  .draw-title {
    font-size: 24px;
  }

  .draw-canvas-wrap canvas {
    max-height: 50vh;
  }

  .chat-input {
    font-size: 15px;
    padding: 10px 14px;
  }
}

@media (max-width: 380px) {
  .tab {
    font-size: 14px;
    padding: 10px 0;
  }

  .credit-badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .announcement-banner {
    font-size: 12px;
    padding: 6px 12px;
  }

  .chat-title {
    font-size: 13px;
  }

  .color-dot {
    width: 26px;
    height: 26px;
  }

  .tool-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}
