:root {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --accent-color: #bb86fc;
  --border-color: #333;
  --input-bg: #1e1e1e;
  --btn-bg: #2c2c2c;
  --btn-active: #3c3c3c;
  --hp-color: #cf6679;
  --mp-color: #03dac6;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'HanYiZhongYuan', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  overflow: hidden;
  font-size: 14px;
}

/* App Container */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 600px; /* Tablet/Desktop constraint */
  margin: 0 auto;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

/* Header */
header {
  height: 44px;
  background-color: #1f1f1f;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
}

header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: normal;
  color: var(--accent-color);
}

/* Main Game Area */
#game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Status Bar (HP/MP) */
#status-bar {
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--border-color);
  min-height: 30px;
}

.stat-item {
  flex: 1;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  height: 20px;
  min-width: 80px;
  border: 1px solid #444;
}

/* Floating Buttons over Output Area */
#out-floating-btns {
    position: fixed;
    top: 40px;
    right: 2px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 2px;
    transition: width 0.2s, height 0.2s;
}

#out-floating-btns.collapsed #float-list {
    display: none;
}

#out-floating-btns .action-btn {
    margin: 1px 0;
    padding: 4px 6px;
    font-size: 11px;
    min-width: 36px;
    opacity: 0.9;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
    display: block;
    width: 100%;
}

#float-handle {
    user-select: none;
    touch-action: none;
    font-size: 14px;
    line-height: 14px;
    padding-bottom: 4px;
    cursor: pointer;
}

#out-floating-btns .action-btn:hover {
    opacity: 1;
}

.stat-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.stat-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 1px 1px 1px #000;
  z-index: 2;
  font-size: 11px;
}

/* Output Log */
#out, #chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-family: monospace;
  line-height: 1.5;
  background-color: var(--bg-color);
  -webkit-overflow-scrolling: touch;
}

#chat {
    border-bottom: 1px solid #333;
    max-height: 30%;
}

.chat-msg {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.out-msg {
    margin-bottom: 4px;
}

/* Bottom Controls */
#bottom-panel {
  background-color: #1f1f1f;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Quick Actions Toolbar */
#quick-actions {
  display: flex;
  overflow-x: auto;
  padding: 5px;
  gap: 5px;
  border-bottom: 1px solid #333;
}

#quick-actions::-webkit-scrollbar {
  display: none;
}

.action-btn {
  background: var(--btn-bg);
  border: 1px solid #444;
  color: #ccc;
  padding: 6px 12px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 12px;
  cursor: pointer;
}

.action-btn:active {
  background: var(--btn-active);
}

/* Input Area */
#input-area {
  display: flex;
  padding: 8px;
  gap: 8px;
  background-color: #1a1a1a;
  border-top: 1px solid #333;
  align-items: center;
}

#cmd-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid #444;
  color: #fff;
  padding: 8px;
  border-radius: 4px;
  outline: none;
  font-size: 14px;
}

#send-btn {
  background: var(--accent-color);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 20px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: all 0.2s;
  font-size: 14px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

#send-btn:active {
  transform: translateY(1px);
  box-shadow: none;
  opacity: 0.9;
}

.exit-btn, .menu-btn, .pop-btn {
    display: inline-block;
    padding: 6px 12px;
    margin: 2px;
    background: #333;
    border: 1px solid #555;
    color: #eee;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
}

.act-btn {
    display: inline-block;
    padding: 6px 12px;
    margin: 2px;
    background: #333;
    border: 1px solid #555;
    color: #eee;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    text-align: center;
}

.obj-btn {
    display: block;
    width: 100%;
    height: 30px;
    line-height: 28px;
    padding: 0 4px;
    margin-bottom: 4px;
    background: #333;
    border: 1px solid #555;
    color: #eee;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h5-btn {
    display: inline-block;
    padding: 8px 12px;
    margin: 5px 0;
    background: #444;
    border: 1px solid #666;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    width: 100%;
}
.h5-btn.primary {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}
.h5-btn.small {
    padding: 4px 8px;
    font-size: 12px;
    width: auto;
}
.h5-input {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: #111;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
}

/* Modal Overlay */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

#modal-overlay.active {
  display: flex;
}

#modal-content {
  background: #252525;
  width: 90%;
  max-width: 400px;
  max-height: 80%;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border: 1px solid #444;
}
