* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
}

.session-gate {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 28, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}

.session-gate.show { display: flex; }

.gate-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  width: min(420px, 100%);
  text-align: center;
}

.gate-card h2 { margin-bottom: 8px; color: #2f2f45; }
.gate-card p { color: #666; line-height: 1.6; }

.header {
  background: rgba(255,255,255,0.95);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.header h1 { font-size: 1.4rem; color: #333; }

#studentName {
  padding: 8px 16px;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 1rem;
  width: 160px;
  outline: none;
}

#studentName:focus { border-color: #667eea; }

.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}

.canvas-wrapper {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-height: 100%;
  max-width: 100%;
}

.canvas-wrapper canvas {
  display: block;
  max-height: calc(100vh - 220px);
  max-width: calc(100vw - 40px);
  width: auto;
  height: auto;
}

#outlineCanvas { position: absolute; top: 0; left: 0; }
#drawCanvas { position: relative; cursor: crosshair; }

.toolbar {
  background: rgba(255,255,255,0.95);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.color-palette { display: flex; gap: 6px; flex-wrap: wrap; }
.color-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer;
}
.color-btn.active { border-color: #333; transform: scale(1.1); }

.brush-sizes { display: flex; align-items: center; gap: 6px; }
.brush-sizes .label { font-size: 0.85rem; color: #666; margin-right: 4px; }
.size-btn {
  width: 40px; height: 40px; border: 2px solid #ddd; border-radius: 50%;
  background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.size-btn.active { border-color: #667eea; background: #f0f0ff; }
.size-btn .dot { background: #333; border-radius: 50%; display: block; }

.tools { display: flex; gap: 6px; }
.tool-btn {
  padding: 8px 14px; border: 2px solid #ddd; border-radius: 20px;
  background: white; font-size: 0.9rem; cursor: pointer;
}
.tool-btn.active { border-color: #667eea; background: #f0f0ff; color: #667eea; }

.complete-btn {
  padding: 12px 28px;
  background: linear-gradient(135deg, #2ECC71, #27AE60);
  color: white; border: none; border-radius: 25px;
  font-size: 1.1rem; font-weight: bold; cursor: pointer;
}
.complete-btn[disabled] {
  background: #9fa3ad;
  cursor: not-allowed;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: white;
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.modal h2 { margin-bottom: 16px; }
.modal p { color: #666; margin-bottom: 20px; }
.preview-wrapper {
  margin: 16px auto; border: 3px solid #ddd; border-radius: 8px;
  display: inline-block; overflow: hidden;
}
.modal-buttons { display: flex; gap: 12px; justify-content: center; }
.btn-cancel, .btn-confirm, .btn-new {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
.btn-cancel { background: #ecf0f1; color: #666; }
.btn-confirm { background: linear-gradient(135deg, #2ECC71, #27AE60); color: white; }
.btn-new { background: linear-gradient(135deg, #667eea, #764ba2); color: white; margin-top: 10px; }

@media (max-width: 600px) {
  .header h1 { font-size: 1.1rem; }
  #studentName { width: 120px; font-size: 0.9rem; }
  .color-btn { width: 32px; height: 32px; }
  .tool-btn { padding: 6px 10px; font-size: 0.8rem; }
}
