:root {
  --bg: #f4f2ea;
  --paper: #fffdf7;
  --ink: #1f2a2c;
  --muted: #58676b;
  --line: #d5d2c7;
  --accent: #2f7b5f;
  --accent-strong: #1f5e47;
  --danger: #b33d2f;
  --danger-strong: #8d2f24;
  --shadow: 0 12px 30px rgba(28, 39, 42, 0.11);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, #f8f6ef 0%, transparent 45%),
    radial-gradient(circle at 88% 8%, #e7efe6 0%, transparent 40%),
    var(--bg);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(255, 252, 242, 0.85);
}

.brand {
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.nav-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.container {
  width: min(960px, 92vw);
  margin: 1.8rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.card.narrow {
  max-width: 460px;
  margin: 0 auto;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

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

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.86rem;
  background: #faf8f1;
}

.inline-form {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

input[type='text'],
input[type='password'],
input[type='file'] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.62rem 0.7rem;
  font-size: 1rem;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.btn-small {
  padding: 0.42rem 0.72rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-strong);
}

.alert {
  border: 1px solid #e9b9b2;
  color: #86271d;
  background: #fff0ee;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
}

.small {
  font-size: 0.88rem;
}

.drive-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
}

.folder-panel,
.file-panel {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.folder-panel h2 {
  margin-bottom: 0;
}

.folder-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.folder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.folder-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.45rem;
  transition: border-color 120ms ease, background 120ms ease;
}

.folder-item.active {
  border-color: #7aa28d;
  background: #f1f8f3;
}

.folder-item.drag-target {
  border-color: var(--accent);
  background: #e7f6ed;
}

.folder-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.folder-label {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.24rem;
}

.folder-delete {
  flex-shrink: 0;
}

.drive-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dropzone {
  border: 2px dashed #88a39b;
  border-radius: 16px;
  padding: 1rem;
  background: #f4fbf7;
  transition: background 120ms ease, border-color 120ms ease;
}

.dropzone.drag-over {
  background: #e9f6ee;
  border-color: var(--accent);
}

.status {
  min-height: 1.4rem;
  margin: 0.8rem 0;
  font-weight: 600;
  color: var(--accent-strong);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.file-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  color: var(--muted);
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0.58rem;
  background: #fff;
}

.file-row.dragging {
  opacity: 0.45;
}

.drag-handle {
  user-select: none;
  cursor: grab;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: monospace;
  color: var(--muted);
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  color: var(--muted);
  font-size: 0.87rem;
  margin-top: 0.18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.preview-text {
  border: 1px solid var(--line);
  background: #fcfcf8;
  border-radius: 14px;
  padding: 0.8rem;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-frame {
  width: 100%;
  min-height: 76vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.preview-image-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: #faf9f2;
  display: flex;
  justify-content: center;
}

.preview-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.game-panel {
  display: grid;
  gap: 0.8rem;
}

.game-stats {
  display: flex;
  gap: 1rem;
  font-weight: 600;
}

.game-board {
  position: relative;
  min-height: 290px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(150deg, #faf8ee 0%, #f1f6ef 100%);
  overflow: hidden;
}

.game-target {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background:
    radial-gradient(circle at 30% 30%, #fff6d7 0%, #f7c356 43%, #b56b16 100%);
  box-shadow: 0 8px 16px rgba(38, 38, 38, 0.2);
  display: none;
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .drive-layout {
    grid-template-columns: 1fr;
  }

  .folder-form {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .file-actions {
    justify-content: flex-start;
  }

  .drag-handle {
    width: fit-content;
  }
}
