/* ── Reset & Base ─────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, monospace; background: #0f0f23; color: #e0e0e0; min-height: 100vh; }
a { color: #4CAF50; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 100%); }
.login-container { background: #1a1a2e; border: 2px solid #4CAF50; border-radius: 12px;
  padding: 40px; width: 360px; text-align: center; box-shadow: 0 0 40px rgba(76,175,80,0.2); }
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: bold; color: #4CAF50; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: #888; margin-bottom: 28px; }
.login-form label { display: block; text-align: left; font-size: 13px; color: #aaa; margin-bottom: 4px; }
.login-form input { width: 100%; background: #0f0f23; border: 1px solid #333; color: #e0e0e0;
  padding: 10px 14px; border-radius: 6px; font-size: 15px; margin-bottom: 16px; outline: none; }
.login-form input:focus { border-color: #4CAF50; }
.login-submit { width: 100%; background: #4CAF50; color: #000; border: none;
  padding: 12px; border-radius: 6px; font-size: 16px; font-weight: bold; }
.login-submit:hover { background: #66BB6A; }
.login-error { color: #f44336; font-size: 13px; margin-top: 10px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.studio-header, .play-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #12122e; border-bottom: 1px solid #2a2a4a;
  position: sticky; top: 0; z-index: 100; }
.logo { font-size: 18px; font-weight: bold; color: #4CAF50; margin-right: 16px; }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; color: #aaa; }
.btn-sm { background: #1e1e3e; border: 1px solid #333; color: #aaa; padding: 5px 12px; border-radius: 4px; font-size: 13px; }
.btn-sm:hover { border-color: #4CAF50; color: #4CAF50; }
.btn-link { color: #4CAF50; font-size: 13px; }

/* ── Game Selector ────────────────────────────────────────────────────────── */
.game-selector { position: relative; }
.btn-selector { background: #1e1e3e; border: 1px solid #4CAF50; color: #4CAF50; padding: 6px 14px; border-radius: 6px; font-size: 13px; }
.btn-selector:hover { background: #252550; }
.selector-panel { position: absolute; top: calc(100% + 6px); left: 0; background: #1a1a2e;
  border: 1px solid #333; border-radius: 8px; min-width: 240px; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-height: 300px; overflow-y: auto; }
.selector-item { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid #222; }
.selector-item:hover { background: #252550; }
.new-game-item { color: #4CAF50; font-weight: bold; }
.selector-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector-badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.badge-done { background: #1b4d1b; color: #4CAF50; }
.badge-spec { background: #2a2a00; color: #FFC107; }
.selector-loading, .selector-empty { padding: 12px 14px; font-size: 13px; color: #666; }
.improve-btn { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #1a2a3a; color: #64b5f6; border: 1px solid #2a4a6a; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.improve-btn:hover { background: #2a3a5a; color: #90caf9; }
.improve-banner { background: linear-gradient(90deg, #1a2a3a, #0d1f2d); border: 1px solid #2a4a6a; border-radius: 8px; color: #64b5f6; font-size: 12px; font-weight: 600; padding: 5px 10px; margin-bottom: 8px; text-align: center; letter-spacing: 0.5px; }

/* ── Studio Layout ────────────────────────────────────────────────────────── */
.studio-layout { display: grid; grid-template-columns: 1fr 380px; height: calc(100vh - 53px); position: relative; }

/* ── Chat Panel ───────────────────────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; border-right: 1px solid #2a2a4a; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; color: #555; padding: 40px; }
.chat-empty-icon { font-size: 48px; margin-bottom: 12px; }
.chat-empty-title { font-size: 18px; font-weight: bold; color: #888; margin-bottom: 8px; }
.chat-empty-text { font-size: 14px; color: #555; }
.chat-msg { display: flex; gap: 8px; max-width: 85%; }
.chat-msg-alice { align-self: flex-start; }
.chat-msg-david { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { font-size: 20px; flex-shrink: 0; align-self: flex-end; }
.msg-bubble { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.chat-msg-alice .msg-bubble { background: #1e1e3e; border: 1px solid #3d3d6e; border-bottom-left-radius: 2px; }
.chat-msg-david .msg-bubble { background: #1a3a1a; border: 1px solid #4CAF50; border-bottom-right-radius: 2px; color: #fff; }

.hint-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px 4px; }
.hint-chip { background: #1e1e3e; border: 1px solid #4CAF50; color: #4CAF50; padding: 5px 12px; border-radius: 20px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.hint-chip:hover { background: #4CAF50; color: #000; }

.chat-input-area { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #2a2a4a; }
.chat-input { flex: 1; background: #1a1a2e; border: 1px solid #333; color: #e0e0e0; padding: 10px 14px; border-radius: 8px; font-size: 14px; outline: none; }
.chat-input:focus { border-color: #4CAF50; }
.chat-input:disabled { opacity: 0.5; }
.btn-send { background: #4CAF50; color: #000; border: none; padding: 10px 20px; border-radius: 8px; font-weight: bold; font-size: 14px; }
.btn-send:hover:not(:disabled) { background: #66BB6A; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.rate-hint { padding: 4px 16px 8px; font-size: 12px; color: #888; font-style: italic; }
.usage-bar { padding: 2px 16px 8px; font-size: 11px; color: #555; }

/* ── Spec Panel ───────────────────────────────────────────────────────────── */
.spec-panel { overflow-y: auto; padding: 16px; background: #12122e; position: relative; }
.spec-empty { display: flex; align-items: center; justify-content: center; height: 200px; color: #555; text-align: center; padding: 20px; }
.spec-header { margin-bottom: 16px; }
.spec-title { font-size: 15px; font-weight: bold; color: #fff; margin-bottom: 10px; }
.spec-progress-wrap { }
.spec-progress-label { font-size: 13px; color: #aaa; margin-bottom: 6px; }
.progress-bar { background: #1e1e1e; border-radius: 6px; height: 10px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.progress-fill.red { background: #f44336; }
.progress-fill.yellow { background: #FFC107; }
.progress-fill.green { background: #4CAF50; }
.spec-tip { font-size: 12px; color: #888; margin-top: 4px; }
.spec-tip.ready { color: #4CAF50; font-weight: bold; }

.spec-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.spec-item { display: flex; align-items: flex-start; gap: 8px; background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 8px; padding: 8px 10px; transition: border-color 0.2s; }
.spec-item.filled { border-color: #2a5a2a; background: #141e14; }
.spec-item.locked { opacity: 0.5; }
.spec-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.spec-text { flex: 1; min-width: 0; }
.spec-label { font-size: 11px; color: #888; display: block; margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.spec-value { font-size: 13px; color: #e0e0e0; word-break: break-word; }
.spec-value.placeholder { color: #555; font-style: italic; }
.spec-status { font-size: 14px; flex-shrink: 0; }
.spec-divider { font-size: 12px; color: #666; margin: 8px 0 4px; text-align: center; }

.build-btn { width: 100%; margin-top: 12px; padding: 14px; background: #4CAF50; color: #000;
  font-weight: bold; font-size: 15px; border: none; border-radius: 8px;
  animation: pulse-green 1.5s ease-in-out infinite; }
.build-btn:hover { background: #66BB6A; animation: none; }
@keyframes pulse-green { 0%,100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.4); } 50% { box-shadow: 0 0 0 8px rgba(76,175,80,0); } }

.game-ready-banner { display: flex; justify-content: center; margin-top: 12px; }
.btn-play-now { background: #4CAF50; color: #000; border: none; padding: 16px 32px; border-radius: 8px; font-size: 18px; font-weight: bold; animation: pulse-green 1.2s ease-in-out infinite; }
.btn-play-now:hover { background: #66BB6A; animation: none; }

/* ── Build Overlay ────────────────────────────────────────────────────────── */
.build-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #12122eee;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px; z-index: 50; border-radius: 0; }
.build-spinner { font-size: 48px; animation: spin 2s linear infinite; margin-bottom: 16px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.build-msg { font-size: 18px; font-weight: bold; color: #4CAF50; margin-bottom: 8px; }
.build-sub { font-size: 13px; color: #888; }
.build-progress-wrap { width: 80%; max-width: 280px; height: 8px; background: #1a1a3a; border-radius: 4px; margin: 12px 0 6px; overflow: hidden; }
.build-progress-bar { height: 100%; background: linear-gradient(90deg, #4CAF50, #81C784); border-radius: 4px; transition: width 1.5s ease; }
.build-steps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 300px; margin: 4px 0; }
.build-step-chip { font-size: 11px; color: #aaa; background: #1a2a1a; border-radius: 12px; padding: 2px 8px; }

/* ── Play Page ────────────────────────────────────────────────────────────── */
.play-page { background: #0f0f23; }
.play-container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.filter-tabs { display: flex; gap: 10px; margin-bottom: 24px; }
.tab { padding: 8px 20px; border: 1px solid #333; background: transparent; color: #888; border-radius: 6px; font-size: 14px; }
.tab.active { background: #4CAF50; color: #000; border-color: #4CAF50; font-weight: bold; }
.tab:hover:not(.active) { border-color: #4CAF50; color: #4CAF50; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.game-card { background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 12px; padding: 20px 16px; text-align: center; transition: border-color 0.2s, transform 0.1s; }
.game-card:hover { border-color: #4CAF50; transform: translateY(-2px); }
.game-card-icon { font-size: 40px; margin-bottom: 10px; }
.game-card-name { font-size: 15px; font-weight: bold; color: #fff; margin-bottom: 6px; }
.game-card-author { font-size: 12px; color: #888; margin-bottom: 14px; }
.game-card-author b { color: #4CAF50; }
.game-card-actions { display: flex; gap: 8px; justify-content: center; }
.btn-play { background: #4CAF50; color: #000; padding: 7px 16px; border-radius: 6px; font-weight: bold; font-size: 13px; }
.btn-play:hover { background: #66BB6A; }
.btn-edit { background: #1e1e3e; border: 1px solid #4CAF50; color: #4CAF50; padding: 7px 14px; border-radius: 6px; font-size: 13px; }
.btn-edit:hover { background: #252550; }
.empty-state { text-align: center; padding: 60px 20px; color: #555; font-size: 16px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.btn-primary { background: #4CAF50; color: #000; padding: 10px 24px; border-radius: 6px; font-weight: bold; font-size: 15px; }
.loading, .error { text-align: center; padding: 40px; color: #888; font-size: 16px; }

/* ── Achievement badge ─────────────────────────────────── */
.achievement-badge { background: linear-gradient(135deg, #1b3a1b, #2a4a2a); color: #81C784; border: 1px solid #2d5a2d; border-radius: 12px; font-size: 12px; font-weight: 600; padding: 4px 10px; display: inline-flex; align-items: center; gap: 4px; }

/* ── My Games dropdown — done game with actions ────────── */
.selector-item-done { flex-direction: column; align-items: stretch; padding: 0; cursor: default; }
.selector-item-done:hover { background: transparent; }
.selector-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px 4px; cursor: pointer; }
.selector-item-top:hover { background: #252550; }
.selector-item-actions { display: flex; gap: 6px; padding: 4px 14px 8px; }
.sel-action-btn { flex: 1; text-align: center; font-size: 11px; padding: 4px 6px; border-radius: 8px; cursor: pointer; border: none; text-decoration: none; font-weight: 600; }
.sel-play { background: #1b3a1b; color: #81C784; }
.sel-play:hover { background: #2d5a2d; }
.sel-improve { background: #1a2a3a; color: #64b5f6; }
.sel-improve:hover { background: #2a3a5a; }
.version-tag { font-size: 10px; background: #1a2a3a; color: #64b5f6; border-radius: 8px; padding: 1px 5px; margin-left: 4px; font-weight: 600; }

/* ── Play page — version & newer version ──────────────── */
.version-badge { font-size: 13px; background: #1a2a3a; color: #64b5f6; border-radius: 10px; padding: 2px 7px; margin-left: 6px; font-weight: 700; vertical-align: middle; }
.newer-version-link { display: block; font-size: 11px; color: #FFC107; background: #2a2000; border-radius: 8px; padding: 3px 8px; margin: 4px 0; text-decoration: none; text-align: center; }
.newer-version-link:hover { background: #3a3000; }
.game-card.has-newer { opacity: 0.8; border-color: #3a3000 !important; }
